warscript 0.0.1-dev.91a4dce → 0.0.1-dev.94cf7fc
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/player.d.ts +2 -1
- package/core/types/player.lua +24 -12
- package/core/types/tileCell.d.ts +2 -1
- package/core/types/tileCell.lua +5 -0
- 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.d.ts +6 -1
- package/engine/behaviour/ability.lua +31 -1
- package/engine/behaviour/unit/stun-immunity.d.ts +7 -5
- package/engine/behaviour/unit/stun-immunity.lua +6 -5
- package/engine/behaviour/unit.d.ts +7 -3
- package/engine/behaviour/unit.lua +101 -24
- package/engine/buff.d.ts +21 -4
- package/engine/buff.lua +142 -44
- 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.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/range-event.d.ts +12 -0
- package/engine/internal/unit/range-event.lua +90 -0
- package/engine/internal/unit/scale.d.ts +7 -0
- package/engine/internal/unit/scale.lua +20 -0
- package/engine/internal/unit-missile-launch.lua +16 -6
- package/engine/internal/unit.d.ts +13 -19
- package/engine/internal/unit.lua +140 -173
- 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/reincarnation.d.ts +8 -0
- package/engine/object-data/entry/ability-type/reincarnation.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 +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 +1 -0
- package/engine/random.lua +8 -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/text-tag.lua +2 -1
- package/engine/unit.d.ts +5 -0
- package/engine/unit.lua +5 -0
- package/objutil/buff.lua +9 -7
- package/package.json +2 -2
- package/patch-lua.lua +15 -0
- package/utility/linked-map.d.ts +34 -0
- package/utility/linked-map.lua +101 -0
- package/utility/linked-set.d.ts +2 -1
- package/utility/linked-set.lua +21 -0
- package/utility/records.lua +20 -1
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
|
-
if not resolveBooleanValue(ability, level, abilityParameterValue) then
|
|
465
|
-
_unit:hideAbility(abilityTypeId, true)
|
|
466
|
-
end
|
|
467
|
-
elseif abilityParameterKey ~= "level" then
|
|
468
|
-
abilityParameterKey:setValue(
|
|
469
|
-
addedAbility,
|
|
470
|
-
resolveNumberValue(ability, level, abilityParameterValue)
|
|
471
|
-
)
|
|
472
|
-
end
|
|
480
|
+
if abilityParameters.isButtonVisible == false then
|
|
481
|
+
_unit:hideAbility(abilityTypeId, true)
|
|
473
482
|
end
|
|
474
|
-
|
|
483
|
+
for ____, field in ipairs(abilityParameters.fields or emptyArray()) do
|
|
484
|
+
field[1]:setValue(
|
|
485
|
+
addedAbility,
|
|
486
|
+
resolveNumberValue(ability, level, field[2])
|
|
487
|
+
)
|
|
488
|
+
end
|
|
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)
|
|
@@ -552,6 +585,9 @@ function Buff.prototype.flashSpecialEffect(self, widgetOrDuration, duration)
|
|
|
552
585
|
__TS__SparseArraySpread(____array_43)
|
|
553
586
|
)
|
|
554
587
|
end
|
|
588
|
+
function Buff.prototype.expire(self)
|
|
589
|
+
expireBuff(self)
|
|
590
|
+
end
|
|
555
591
|
function Buff.prototype.onCreate(self)
|
|
556
592
|
end
|
|
557
593
|
function Buff.prototype.onDestroy(self)
|
|
@@ -580,6 +616,12 @@ function Buff.prototype.onDestroy(self)
|
|
|
580
616
|
behavior:destroy()
|
|
581
617
|
end
|
|
582
618
|
end
|
|
619
|
+
local previousAbilityCooldownModifier = self[144]
|
|
620
|
+
if previousAbilityCooldownModifier then
|
|
621
|
+
for ____, ability in ipairs(self._unit.abilities) do
|
|
622
|
+
COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, previousAbilityCooldownModifier)
|
|
623
|
+
end
|
|
624
|
+
end
|
|
583
625
|
if self[139] then
|
|
584
626
|
unit:decrementInvulnerabilityCounter()
|
|
585
627
|
end
|
|
@@ -588,7 +630,7 @@ function Buff.prototype.onDestroy(self)
|
|
|
588
630
|
end
|
|
589
631
|
if self[136] then
|
|
590
632
|
if self[137] then
|
|
591
|
-
unit:
|
|
633
|
+
unit:decrementForceStunCounter()
|
|
592
634
|
end
|
|
593
635
|
unit:decrementStunCounter()
|
|
594
636
|
end
|
|
@@ -596,7 +638,7 @@ function Buff.prototype.onDestroy(self)
|
|
|
596
638
|
unit:decrementGhostCounter()
|
|
597
639
|
end
|
|
598
640
|
if self._abilityTypeIds ~= nil then
|
|
599
|
-
for abilityTypeId in
|
|
641
|
+
for ____, abilityTypeId in ipairs(self._abilityTypeIds) do
|
|
600
642
|
unit:removeAbility(abilityTypeId)
|
|
601
643
|
end
|
|
602
644
|
end
|
|
@@ -987,13 +1029,13 @@ __TS__SetDescriptor(
|
|
|
987
1029
|
set = function(self, stuns)
|
|
988
1030
|
if not stuns and self[136] then
|
|
989
1031
|
if self[137] then
|
|
990
|
-
self.object:
|
|
1032
|
+
self.object:decrementForceStunCounter()
|
|
991
1033
|
end
|
|
992
1034
|
self.object:decrementStunCounter()
|
|
993
1035
|
self[136] = nil
|
|
994
1036
|
elseif stuns and not self[136] then
|
|
995
1037
|
if self[137] then
|
|
996
|
-
self.object:
|
|
1038
|
+
self.object:incrementForceStunCounter()
|
|
997
1039
|
end
|
|
998
1040
|
self.object:incrementStunCounter()
|
|
999
1041
|
self[136] = true
|
|
@@ -1016,12 +1058,12 @@ __TS__SetDescriptor(
|
|
|
1016
1058
|
set = function(self, ignoresStunImmunity)
|
|
1017
1059
|
if not ignoresStunImmunity and self[137] then
|
|
1018
1060
|
if self[136] then
|
|
1019
|
-
self.object:
|
|
1061
|
+
self.object:decrementForceStunCounter()
|
|
1020
1062
|
end
|
|
1021
1063
|
self[137] = nil
|
|
1022
1064
|
elseif ignoresStunImmunity and not self[137] then
|
|
1023
1065
|
if self[136] then
|
|
1024
|
-
self.object:
|
|
1066
|
+
self.object:incrementForceStunCounter()
|
|
1025
1067
|
end
|
|
1026
1068
|
self[137] = true
|
|
1027
1069
|
end
|
|
@@ -1220,12 +1262,39 @@ __TS__SetDescriptor(
|
|
|
1220
1262
|
},
|
|
1221
1263
|
true
|
|
1222
1264
|
)
|
|
1265
|
+
__TS__SetDescriptor(
|
|
1266
|
+
Buff.prototype,
|
|
1267
|
+
"manaRegenerationRateIncreaseFactor",
|
|
1268
|
+
{
|
|
1269
|
+
get = function(self)
|
|
1270
|
+
return self:getUnitBonus(UnitBonusType.MANA_REGENERATION_RATE_FACTOR)
|
|
1271
|
+
end,
|
|
1272
|
+
set = function(self, manaRegenerationRateIncreaseFactor)
|
|
1273
|
+
self:addOrUpdateOrRemoveUnitBonus(UnitBonusType.MANA_REGENERATION_RATE_FACTOR, manaRegenerationRateIncreaseFactor)
|
|
1274
|
+
end
|
|
1275
|
+
},
|
|
1276
|
+
true
|
|
1277
|
+
)
|
|
1223
1278
|
__TS__SetDescriptor(
|
|
1224
1279
|
Buff.prototype,
|
|
1225
1280
|
"duration",
|
|
1226
|
-
{
|
|
1227
|
-
|
|
1228
|
-
|
|
1281
|
+
{
|
|
1282
|
+
get = function(self)
|
|
1283
|
+
return self[103]
|
|
1284
|
+
end,
|
|
1285
|
+
set = function(self, duration)
|
|
1286
|
+
if duration <= 0 then
|
|
1287
|
+
local timer = self._timer
|
|
1288
|
+
if timer ~= nil then
|
|
1289
|
+
timer:destroy()
|
|
1290
|
+
self._timer = nil
|
|
1291
|
+
end
|
|
1292
|
+
self[103] = 0
|
|
1293
|
+
else
|
|
1294
|
+
self.remainingDuration = self.remainingDuration + (duration - self[103])
|
|
1295
|
+
end
|
|
1296
|
+
end
|
|
1297
|
+
},
|
|
1229
1298
|
true
|
|
1230
1299
|
)
|
|
1231
1300
|
__TS__SetDescriptor(
|
|
@@ -1269,6 +1338,32 @@ __TS__SetDescriptor(
|
|
|
1269
1338
|
},
|
|
1270
1339
|
true
|
|
1271
1340
|
)
|
|
1341
|
+
__TS__SetDescriptor(
|
|
1342
|
+
Buff.prototype,
|
|
1343
|
+
"abilityCooldownFactor",
|
|
1344
|
+
{
|
|
1345
|
+
get = function(self)
|
|
1346
|
+
return self[143] or 1
|
|
1347
|
+
end,
|
|
1348
|
+
set = function(self, abilityCooldownFactor)
|
|
1349
|
+
local previousAbilityCooldownModifier = self[144]
|
|
1350
|
+
if previousAbilityCooldownModifier then
|
|
1351
|
+
for ____, ability in ipairs(self._unit.abilities) do
|
|
1352
|
+
COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:removeModifier(ability, previousAbilityCooldownModifier)
|
|
1353
|
+
end
|
|
1354
|
+
end
|
|
1355
|
+
local function modifier(ability, level, cooldown)
|
|
1356
|
+
return cooldown * abilityCooldownFactor
|
|
1357
|
+
end
|
|
1358
|
+
for ____, ability in ipairs(self._unit.abilities) do
|
|
1359
|
+
COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD:applyModifier(ability, modifier)
|
|
1360
|
+
end
|
|
1361
|
+
self[144] = modifier
|
|
1362
|
+
self[143] = abilityCooldownFactor
|
|
1363
|
+
end
|
|
1364
|
+
},
|
|
1365
|
+
true
|
|
1366
|
+
)
|
|
1272
1367
|
Buff.createdEvent = buffCreatedEvent
|
|
1273
1368
|
Buff.beingDestroyedEvent = buffBeingDestroyedEvent;
|
|
1274
1369
|
(function(self)
|
|
@@ -1327,5 +1422,8 @@ Buff.beingDestroyedEvent = buffBeingDestroyedEvent;
|
|
|
1327
1422
|
buffCreatedEvent:addListener(function(buff)
|
|
1328
1423
|
UnitBehavior:forAll(buff.unit, "onBuffGained", buff)
|
|
1329
1424
|
end)
|
|
1425
|
+
buffBeingDestroyedEvent:addListener(function(buff)
|
|
1426
|
+
UnitBehavior:forAll(buff.unit, "onBuffLost", buff)
|
|
1427
|
+
end)
|
|
1330
1428
|
end)(Buff)
|
|
1331
1429
|
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
|
|
@@ -12,6 +12,7 @@ export type UnitAutoAttackDamageBonusId = UnitBonusId<"autoAttackDamage">;
|
|
|
12
12
|
export type UnitDamageFactorBonusId = UnitBonusId<"damageFactor">;
|
|
13
13
|
export type UnitReceivedDamageFactorBonusId = UnitBonusId<"receivedDamageFactor">;
|
|
14
14
|
export type UnitEvasionProbabilityBonusId = UnitBonusId<"evasionProbability">;
|
|
15
|
+
export type UnitManaRegenerationRateFactorBonusId = UnitBonusId<"manaRegenerationRateFactor">;
|
|
15
16
|
export type UnitBonusType<Id extends UnitBonusId = UnitBonusId> = ({
|
|
16
17
|
abilityTypeId: AbilityTypeId;
|
|
17
18
|
field: jabilityintegerlevelfield;
|
|
@@ -36,6 +37,7 @@ export declare namespace UnitBonusType {
|
|
|
36
37
|
const DAMAGE_FACTOR: UnitBonusType<UnitReceivedDamageFactorBonusId>;
|
|
37
38
|
const RECEIVED_DAMAGE_FACTOR: UnitBonusType<UnitReceivedDamageFactorBonusId>;
|
|
38
39
|
const EVASION_PROBABILITY: UnitBonusType<UnitEvasionProbabilityBonusId>;
|
|
40
|
+
const MANA_REGENERATION_RATE_FACTOR: UnitBonusType<UnitManaRegenerationRateFactorBonusId>;
|
|
39
41
|
}
|
|
40
42
|
export declare const addUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, value: number) => Id;
|
|
41
43
|
export declare const removeUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, id: Id) => boolean;
|
|
@@ -24,6 +24,9 @@ local MOVEMENT_SPEED_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID = ____movement_2Dspee
|
|
|
24
24
|
local ____evasion_2Dprobability = require("engine.internal.object-data.evasion-probability")
|
|
25
25
|
local EVASION_PROBABILITY_ABILITY_FIELD = ____evasion_2Dprobability.EVASION_PROBABILITY_ABILITY_FIELD
|
|
26
26
|
local EVASION_PROBABILITY_DUMMY_ABILITY_TYPE_ID = ____evasion_2Dprobability.EVASION_PROBABILITY_DUMMY_ABILITY_TYPE_ID
|
|
27
|
+
local ____mana_2Dregeneration_2Drate_2Dincrease_2Dfactor = require("engine.internal.object-data.mana-regeneration-rate-increase-factor")
|
|
28
|
+
local MANA_REGENERATION_RATE_INCREASE_FACTOR_ABILITY_FIELD = ____mana_2Dregeneration_2Drate_2Dincrease_2Dfactor.MANA_REGENERATION_RATE_INCREASE_FACTOR_ABILITY_FIELD
|
|
29
|
+
local MANA_REGENERATION_RATE_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID = ____mana_2Dregeneration_2Drate_2Dincrease_2Dfactor.MANA_REGENERATION_RATE_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID
|
|
27
30
|
local damageFactorByUnit = {}
|
|
28
31
|
local receivedDamageFactorByUnit = {}
|
|
29
32
|
local function atLeastOnceProbability(array)
|
|
@@ -73,6 +76,13 @@ do
|
|
|
73
76
|
reduce = atLeastOnceProbability,
|
|
74
77
|
initialValue = 0
|
|
75
78
|
}
|
|
79
|
+
UnitBonusType.MANA_REGENERATION_RATE_FACTOR = {
|
|
80
|
+
abilityTypeId = MANA_REGENERATION_RATE_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID,
|
|
81
|
+
field = MANA_REGENERATION_RATE_INCREASE_FACTOR_ABILITY_FIELD,
|
|
82
|
+
integer = false,
|
|
83
|
+
reduce = sum,
|
|
84
|
+
initialValue = 0
|
|
85
|
+
}
|
|
76
86
|
end
|
|
77
87
|
local bonusesByUnitByBonusType = {}
|
|
78
88
|
local nextId = 1
|
|
@@ -0,0 +1,20 @@
|
|
|
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 FLY_HEIGHT_UNIT_FIELD = ____unit.FLY_HEIGHT_UNIT_FIELD
|
|
8
|
+
__TS__ObjectDefineProperty(
|
|
9
|
+
Unit.prototype,
|
|
10
|
+
"flyHeight",
|
|
11
|
+
{
|
|
12
|
+
get = function(self)
|
|
13
|
+
return FLY_HEIGHT_UNIT_FIELD:getValue(self)
|
|
14
|
+
end,
|
|
15
|
+
set = function(self, value)
|
|
16
|
+
FLY_HEIGHT_UNIT_FIELD:setValue(self, value)
|
|
17
|
+
end
|
|
18
|
+
}
|
|
19
|
+
)
|
|
20
|
+
return ____exports
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local ____unit = require("engine.internal.unit")
|
|
3
|
+
local Unit = ____unit.Unit
|
|
4
|
+
local ____unit_2Dmissile_2Dlaunch = require("engine.internal.unit-missile-launch")
|
|
5
|
+
local resetAutoAttackTimer = ____unit_2Dmissile_2Dlaunch.resetAutoAttackTimer
|
|
6
|
+
local unitDisableAbility = BlzUnitDisableAbility
|
|
7
|
+
local unitInterruptAttack = BlzUnitInterruptAttack
|
|
8
|
+
Unit.prototype.interruptAttack = function(self)
|
|
9
|
+
unitInterruptAttack(self.handle)
|
|
10
|
+
resetAutoAttackTimer(self)
|
|
11
|
+
end
|
|
12
|
+
Unit.prototype.interruptMovement = function(self)
|
|
13
|
+
local handle = self.handle
|
|
14
|
+
unitDisableAbility(
|
|
15
|
+
handle,
|
|
16
|
+
fourCC("Amov"),
|
|
17
|
+
true,
|
|
18
|
+
false
|
|
19
|
+
)
|
|
20
|
+
unitDisableAbility(
|
|
21
|
+
handle,
|
|
22
|
+
fourCC("Amov"),
|
|
23
|
+
false,
|
|
24
|
+
false
|
|
25
|
+
)
|
|
26
|
+
resetAutoAttackTimer(self)
|
|
27
|
+
end
|
|
28
|
+
return ____exports
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import { Event } from "../../../event";
|
|
3
|
+
declare module "../unit" {
|
|
4
|
+
interface Unit {
|
|
5
|
+
readonly unitInRangeEvent: Record<number, Event<[unit: Unit, range: number, unitInRange: Unit]>>;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
declare module "../unit" {
|
|
9
|
+
interface Unit {
|
|
10
|
+
readonly unitOutOfRangeEvent: Record<number, Event<[unit: Unit, range: number, unitOutOfRange: Unit]>>;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__New = ____lualib.__TS__New
|
|
3
|
+
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
4
|
+
local ____exports = {}
|
|
5
|
+
local ____event = require("event")
|
|
6
|
+
local Event = ____event.Event
|
|
7
|
+
local InitializingEvent = ____event.InitializingEvent
|
|
8
|
+
local TriggerEvent = ____event.TriggerEvent
|
|
9
|
+
local ____unit = require("engine.internal.unit")
|
|
10
|
+
local Unit = ____unit.Unit
|
|
11
|
+
local ____timer = require("core.types.timer")
|
|
12
|
+
local Timer = ____timer.Timer
|
|
13
|
+
local ____attributes = require("attributes")
|
|
14
|
+
local attribute = ____attributes.attribute
|
|
15
|
+
local ____linked_2Dmap = require("utility.linked-map")
|
|
16
|
+
local mutableLinkedMap = ____linked_2Dmap.mutableLinkedMap
|
|
17
|
+
local ____linked_2Dset = require("utility.linked-set")
|
|
18
|
+
local LinkedSet = ____linked_2Dset.LinkedSet
|
|
19
|
+
local mutableLinkedSet = ____linked_2Dset.mutableLinkedSet
|
|
20
|
+
local getTriggerUnit = GetTriggerUnit
|
|
21
|
+
local triggerRegisterUnitInRange = TriggerRegisterUnitInRange
|
|
22
|
+
local eventInvoke = Event.invoke
|
|
23
|
+
__TS__ObjectDefineProperty(
|
|
24
|
+
Unit.prototype,
|
|
25
|
+
"unitInRangeEvent",
|
|
26
|
+
{get = function(self)
|
|
27
|
+
local unit = self
|
|
28
|
+
local handle = self.handle
|
|
29
|
+
local unitInRangeEvent = setmetatable(
|
|
30
|
+
{},
|
|
31
|
+
{__index = function(self, value)
|
|
32
|
+
local event = __TS__New(
|
|
33
|
+
TriggerEvent,
|
|
34
|
+
function(trigger)
|
|
35
|
+
triggerRegisterUnitInRange(trigger, handle, value, nil)
|
|
36
|
+
end,
|
|
37
|
+
function() return unit, value, Unit:of(getTriggerUnit()) end
|
|
38
|
+
)
|
|
39
|
+
rawset(self, value, event)
|
|
40
|
+
return event
|
|
41
|
+
end}
|
|
42
|
+
)
|
|
43
|
+
rawset(self, "unitInRangeEvent", unitInRangeEvent)
|
|
44
|
+
return unitInRangeEvent
|
|
45
|
+
end}
|
|
46
|
+
)
|
|
47
|
+
local units = __TS__New(LinkedSet)
|
|
48
|
+
local unitsInRangeByRangeAttribute = attribute()
|
|
49
|
+
local function registerUnitOfRangeEvent(unit, range, unitInRange)
|
|
50
|
+
units:add(unit)
|
|
51
|
+
unit:getOrPut(unitsInRangeByRangeAttribute, mutableLinkedMap):getOrPut(range, mutableLinkedSet):add(unitInRange)
|
|
52
|
+
end
|
|
53
|
+
__TS__ObjectDefineProperty(
|
|
54
|
+
Unit.prototype,
|
|
55
|
+
"unitOutOfRangeEvent",
|
|
56
|
+
{get = function(self)
|
|
57
|
+
local unit = self
|
|
58
|
+
local unitOutOfRangeEvent = setmetatable(
|
|
59
|
+
{},
|
|
60
|
+
{__index = function(self, value)
|
|
61
|
+
local event = __TS__New(
|
|
62
|
+
InitializingEvent,
|
|
63
|
+
function()
|
|
64
|
+
unit.unitInRangeEvent[value]:addListener(999999, registerUnitOfRangeEvent)
|
|
65
|
+
end
|
|
66
|
+
)
|
|
67
|
+
rawset(self, value, event)
|
|
68
|
+
return event
|
|
69
|
+
end}
|
|
70
|
+
)
|
|
71
|
+
rawset(self, "unitOutOfRangeEvent", unitOutOfRangeEvent)
|
|
72
|
+
return unitOutOfRangeEvent
|
|
73
|
+
end}
|
|
74
|
+
)
|
|
75
|
+
Timer.onPeriod[1]:addListener(function()
|
|
76
|
+
for unit in pairs(units) do
|
|
77
|
+
local unitsInRangeByRange = unit[unitsInRangeByRangeAttribute]
|
|
78
|
+
if unitsInRangeByRange ~= nil then
|
|
79
|
+
for range, unitsInRange in pairs(unitsInRangeByRange) do
|
|
80
|
+
for unitInRange in pairs(unitsInRange) do
|
|
81
|
+
if unit:getDistanceTo(unitInRange) > range then
|
|
82
|
+
unitsInRange:remove(unitInRange)
|
|
83
|
+
eventInvoke(unit.unitOutOfRangeEvent[range], unit, range, unitInRange)
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end)
|
|
90
|
+
return ____exports
|