warscript 0.0.1-dev.671d3cf → 0.0.1-dev.6fe4470
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/engine/behaviour/ability/apply-buff.d.ts +3 -5
- package/engine/buff.d.ts +29 -11
- package/engine/buff.lua +127 -61
- package/engine/internal/unit.d.ts +1 -0
- package/engine/internal/unit.lua +1 -0
- package/engine/object-field/ability.d.ts +17 -0
- package/engine/object-field/ability.lua +50 -0
- package/package.json +1 -1
- package/utility/linked-set.d.ts +11 -2
- package/utility/linked-set.lua +5 -2
- package/utility/types.d.ts +1 -0
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
import { AbilityBehavior } from "../ability";
|
|
3
3
|
import { Ability } from "../../internal/ability";
|
|
4
|
-
import { Buff, BuffConstructor, BuffParameters, BuffTypeIdSelectionPolicy } from "../../buff";
|
|
4
|
+
import { Buff, BuffConstructor, BuffParameters, BuffPolarityParameterType, BuffResistanceTypeParameterType, BuffTypeIdSelectionPolicy } from "../../buff";
|
|
5
5
|
import { Unit } from "../../internal/unit";
|
|
6
6
|
import { ApplicableBuffTypeId } from "../../object-data/entry/buff-type/applicable";
|
|
7
|
-
import { BuffResistanceType } from "../../object-data/auxiliary/buff-resistance-type";
|
|
8
|
-
import { BuffPolarity } from "../../object-data/auxiliary/buff-polarity";
|
|
9
7
|
import { Widget } from "../../../core/types/widget";
|
|
10
8
|
type BuffParametersType<T extends BuffConstructor> = BuffParameters & Omit<BuffAdditionalParametersType<T>, keyof BuffParameters>;
|
|
11
9
|
type BuffAdditionalParametersType<T extends BuffConstructor> = T extends BuffConstructor<Buff<infer AdditionalParameters>> ? AdditionalParameters : never;
|
|
@@ -17,8 +15,8 @@ export declare abstract class ApplyBuffAbilityBehavior<T extends BuffConstructor
|
|
|
17
15
|
typeIds: [ApplicableBuffTypeId, ...ApplicableBuffTypeId[]],
|
|
18
16
|
typeIdSelectionPolicy: BuffTypeIdSelectionPolicy
|
|
19
17
|
],
|
|
20
|
-
polarity:
|
|
21
|
-
resistanceType:
|
|
18
|
+
polarity: BuffPolarityParameterType,
|
|
19
|
+
resistanceType: BuffResistanceTypeParameterType,
|
|
22
20
|
parameters?: BuffParametersType<T>
|
|
23
21
|
]);
|
|
24
22
|
}
|
package/engine/buff.d.ts
CHANGED
|
@@ -5,16 +5,19 @@ import { Ability } from "./internal/ability";
|
|
|
5
5
|
import { AbilityTypeId } from "./object-data/entry/ability-type";
|
|
6
6
|
import { BuffPolarity } from "./object-data/auxiliary/buff-polarity";
|
|
7
7
|
import { BuffResistanceType } from "./object-data/auxiliary/buff-resistance-type";
|
|
8
|
-
import { AbilityBooleanField, AbilityBooleanLevelField, AbilityCombatClassificationsLevelField, AbilityDependentValue, AbilityIntegerField, AbilityIntegerLevelField, AbilityNumberField, AbilityNumberLevelField } from "./object-field/ability";
|
|
8
|
+
import { AbilityBooleanField, AbilityBooleanLevelField, AbilityCombatClassificationsLevelField, AbilityDependentValue, AbilityEnumLevelField, AbilityIntegerField, AbilityIntegerLevelField, AbilityNumberField, AbilityNumberLevelField } from "./object-field/ability";
|
|
9
9
|
import { CombatClassifications } from "./object-data/auxiliary/combat-classification";
|
|
10
|
-
import { IsExactlyAny,
|
|
10
|
+
import { IsExactlyAny, Prohibit, ReadonlyNonEmptyArray } from "../utility/types";
|
|
11
11
|
import { UnitBehavior } from "./behaviour/unit";
|
|
12
12
|
import type { Widget } from "../core/types/widget";
|
|
13
13
|
import { Destructor } from "../destroyable";
|
|
14
14
|
export type BuffConstructor<T extends Buff<any> = Buff<any>, Args extends any[] = any> = OmitConstructor<typeof Buff<any>> & (new (...args: Args) => T);
|
|
15
|
+
type EnumParameterValueType<T extends number> = T | AbilityEnumLevelField<T>;
|
|
15
16
|
type NumberParameterValueType = number | AbilityNumberField | AbilityNumberLevelField;
|
|
16
17
|
type IntegerParameterValueType = number | AbilityIntegerField | AbilityIntegerLevelField;
|
|
17
18
|
type BooleanParameterValueType = boolean | AbilityBooleanField | AbilityBooleanLevelField;
|
|
19
|
+
export type BuffPolarityParameterType = EnumParameterValueType<BuffPolarity>;
|
|
20
|
+
export type BuffResistanceTypeParameterType = EnumParameterValueType<BuffResistanceType>;
|
|
18
21
|
export declare class BuffUniqueGroup {
|
|
19
22
|
}
|
|
20
23
|
export type BuffParameters<T extends Buff<any> = Buff> = Buff extends T ? {
|
|
@@ -64,6 +67,8 @@ export type BuffParameters<T extends Buff<any> = Buff> = Buff extends T ? {
|
|
|
64
67
|
disablesAutoAttack?: BooleanParameterValueType;
|
|
65
68
|
destroysOnDamage?: BooleanParameterValueType;
|
|
66
69
|
maximumAutoAttackCount?: IntegerParameterValueType;
|
|
70
|
+
maximumDamageDealtEventCount?: IntegerParameterValueType;
|
|
71
|
+
maximumDamageReceivedEventCount?: IntegerParameterValueType;
|
|
67
72
|
damageOnExpiration?: NumberParameterValueType;
|
|
68
73
|
healingOnExpiration?: NumberParameterValueType;
|
|
69
74
|
killsOnExpiration?: BooleanParameterValueType;
|
|
@@ -101,12 +106,16 @@ declare const enum BuffPropertyKey {
|
|
|
101
106
|
SMALL_DAMAGE_UPON_DEATH_RANGE = 127,
|
|
102
107
|
AUTO_ATTACK_COUNT = 128,
|
|
103
108
|
MAXIMUM_AUTO_ATTACK_COUNT = 129,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
DAMAGE_DEALT_EVENT_COUNT = 130,
|
|
110
|
+
MAXIMUM_DAMAGE_DEALT_EVENT_COUNT = 131,
|
|
111
|
+
DAMAGE_RECEIVED_EVENT_COUNT = 132,
|
|
112
|
+
MAXIMUM_DAMAGE_RECEIVED_EVENT_COUNT = 133,
|
|
113
|
+
STUNS = 134,
|
|
114
|
+
IGNORES_STUN_IMMUNITY = 135,
|
|
115
|
+
DISABLES_AUTO_ATTACK = 136,
|
|
116
|
+
PROVIDES_INVULNERABILITY = 137,
|
|
117
|
+
KILLS_ON_EXPIRATION = 138,
|
|
118
|
+
EXPLODES_ON_EXPIRATION = 139
|
|
110
119
|
}
|
|
111
120
|
export declare const enum BuffTypeIdSelectionPolicy {
|
|
112
121
|
LEAST_DURATION = 0
|
|
@@ -114,11 +123,11 @@ export declare const enum BuffTypeIdSelectionPolicy {
|
|
|
114
123
|
export type BuffAdditionalParameters = Prohibit<Record<string, any>, keyof BuffParameters>;
|
|
115
124
|
export type BuffConstructorParameters<AdditionalParameters extends BuffAdditionalParameters> = [
|
|
116
125
|
...typeId: [ApplicableBuffTypeId] | [
|
|
117
|
-
typeIds:
|
|
126
|
+
typeIds: ReadonlyNonEmptyArray<ApplicableBuffTypeId>,
|
|
118
127
|
typeIdSelectionPolicy: BuffTypeIdSelectionPolicy
|
|
119
128
|
],
|
|
120
|
-
polarity:
|
|
121
|
-
resistanceType:
|
|
129
|
+
polarity: BuffPolarityParameterType,
|
|
130
|
+
resistanceType: BuffResistanceTypeParameterType,
|
|
122
131
|
...abilityOrParameters: [
|
|
123
132
|
ability: Ability,
|
|
124
133
|
parameters?: BuffParameters & Omit<AdditionalParameters, keyof BuffParameters>
|
|
@@ -157,6 +166,10 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
|
|
|
157
166
|
private [BuffPropertyKey.SMALL_DAMAGE_UPON_DEATH_RANGE]?;
|
|
158
167
|
private [BuffPropertyKey.MAXIMUM_AUTO_ATTACK_COUNT]?;
|
|
159
168
|
private [BuffPropertyKey.AUTO_ATTACK_COUNT]?;
|
|
169
|
+
private [BuffPropertyKey.MAXIMUM_DAMAGE_DEALT_EVENT_COUNT]?;
|
|
170
|
+
private [BuffPropertyKey.DAMAGE_DEALT_EVENT_COUNT]?;
|
|
171
|
+
private [BuffPropertyKey.MAXIMUM_DAMAGE_RECEIVED_EVENT_COUNT]?;
|
|
172
|
+
private [BuffPropertyKey.DAMAGE_RECEIVED_EVENT_COUNT]?;
|
|
160
173
|
private [BuffPropertyKey.STUNS]?;
|
|
161
174
|
private [BuffPropertyKey.IGNORES_STUN_IMMUNITY]?;
|
|
162
175
|
private [BuffPropertyKey.DISABLES_AUTO_ATTACK]?;
|
|
@@ -219,6 +232,10 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
|
|
|
219
232
|
set killsOnExpiration(killsOnExpiration: boolean);
|
|
220
233
|
get explodesOnExpiration(): boolean;
|
|
221
234
|
set explodesOnExpiration(killsOnExpiration: boolean);
|
|
235
|
+
get maximumDamageDealtEventCount(): number;
|
|
236
|
+
set maximumDamageDealtEventCount(maximumDamageDealtEventCount: number);
|
|
237
|
+
get maximumDamageReceivedEventCount(): number;
|
|
238
|
+
set maximumDamageReceivedEventCount(maximumDamageReceivedEventCount: number);
|
|
222
239
|
get maximumAutoAttackCount(): number;
|
|
223
240
|
set maximumAutoAttackCount(maximumAutoAttackCount: number);
|
|
224
241
|
get durationIncreaseOnAutoAttack(): number;
|
|
@@ -238,5 +255,6 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
|
|
|
238
255
|
onExpiration(): void;
|
|
239
256
|
onDeath(source: Unit | undefined): void;
|
|
240
257
|
onDamageDealt(target: Unit, event: DamageEvent): void;
|
|
258
|
+
onDamageReceived(source: Unit | undefined, event: DamageEvent): void;
|
|
241
259
|
}
|
|
242
260
|
export {};
|
package/engine/buff.lua
CHANGED
|
@@ -107,12 +107,26 @@ local buffParametersKeys = {
|
|
|
107
107
|
disablesAutoAttack = true,
|
|
108
108
|
destroysOnDamage = true,
|
|
109
109
|
maximumAutoAttackCount = true,
|
|
110
|
+
maximumDamageDealtEventCount = true,
|
|
111
|
+
maximumDamageReceivedEventCount = true,
|
|
110
112
|
uniqueGroup = true,
|
|
111
113
|
damageOnExpiration = true,
|
|
112
114
|
healingOnExpiration = true,
|
|
113
115
|
killsOnExpiration = true,
|
|
114
116
|
explodesOnExpiration = true
|
|
115
117
|
}
|
|
118
|
+
local function resolveEnumValue(ability, level, value)
|
|
119
|
+
if value == nil or type(value) == "number" then
|
|
120
|
+
return value
|
|
121
|
+
end
|
|
122
|
+
if ability == nil then
|
|
123
|
+
error(
|
|
124
|
+
__TS__New(IllegalArgumentException),
|
|
125
|
+
0
|
|
126
|
+
)
|
|
127
|
+
end
|
|
128
|
+
return value:getValue(ability, level or ability.level)
|
|
129
|
+
end
|
|
116
130
|
local function resolveNumberValue(ability, level, value)
|
|
117
131
|
if value == nil or type(value) == "number" then
|
|
118
132
|
return value
|
|
@@ -164,6 +178,8 @@ local buffNumberParameters = {
|
|
|
164
178
|
"armorIncrease",
|
|
165
179
|
"receivedDamageFactor",
|
|
166
180
|
"maximumAutoAttackCount",
|
|
181
|
+
"maximumDamageDealtEventCount",
|
|
182
|
+
"maximumDamageReceivedEventCount",
|
|
167
183
|
"damageInterval",
|
|
168
184
|
"damagePerInterval",
|
|
169
185
|
"damageOverDuration",
|
|
@@ -310,8 +326,6 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
|
|
|
310
326
|
end
|
|
311
327
|
end
|
|
312
328
|
self.typeId = typeId
|
|
313
|
-
self.polarity = polarity
|
|
314
|
-
self.resistanceType = resistanceType
|
|
315
329
|
if not __TS__InstanceOf(ability, Ability) then
|
|
316
330
|
parameters = ability
|
|
317
331
|
ability = nil
|
|
@@ -338,6 +352,8 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
|
|
|
338
352
|
learnLevelMinimum = learnLevelMinimum or ability:getField(ABILITY_IF_REQUIRED_LEVEL)
|
|
339
353
|
duration = duration or getAbilityDuration(ability, _unit)
|
|
340
354
|
end
|
|
355
|
+
self.polarity = resolveEnumValue(ability, level, polarity)
|
|
356
|
+
self.resistanceType = resolveEnumValue(ability, level, resistanceType)
|
|
341
357
|
local buffByTypeId = buffByTypeIdByUnit[_unit]
|
|
342
358
|
if buffByTypeId == nil then
|
|
343
359
|
buffByTypeId = {}
|
|
@@ -354,8 +370,8 @@ function Buff.prototype.____constructor(self, _unit, typeIdOrTypeIds, polarityOr
|
|
|
354
370
|
if not internalApplyBuff(
|
|
355
371
|
_unit,
|
|
356
372
|
typeId,
|
|
357
|
-
polarity,
|
|
358
|
-
resistanceType,
|
|
373
|
+
self.polarity,
|
|
374
|
+
self.resistanceType,
|
|
359
375
|
level,
|
|
360
376
|
duration,
|
|
361
377
|
spellStealPriority,
|
|
@@ -544,11 +560,11 @@ function Buff.prototype.onDestroy(self)
|
|
|
544
560
|
behavior:destroy()
|
|
545
561
|
end
|
|
546
562
|
end
|
|
547
|
-
if self[
|
|
563
|
+
if self[136] then
|
|
548
564
|
unit:decrementDisableAutoAttackCounter()
|
|
549
565
|
end
|
|
550
|
-
if self[
|
|
551
|
-
if self[
|
|
566
|
+
if self[134] then
|
|
567
|
+
if self[135] then
|
|
552
568
|
unit:decrementStunCounter()
|
|
553
569
|
end
|
|
554
570
|
unit:decrementStunCounter()
|
|
@@ -605,9 +621,9 @@ function Buff.prototype.onExpiration(self)
|
|
|
605
621
|
if self[120] ~= nil then
|
|
606
622
|
(self[101] or unit):healTarget(unit, self[119] or 0)
|
|
607
623
|
end
|
|
608
|
-
if self[
|
|
624
|
+
if self[139] then
|
|
609
625
|
unit:explode()
|
|
610
|
-
elseif self[
|
|
626
|
+
elseif self[138] then
|
|
611
627
|
unit:kill()
|
|
612
628
|
end
|
|
613
629
|
end
|
|
@@ -652,6 +668,22 @@ function Buff.prototype.onDamageDealt(self, target, event)
|
|
|
652
668
|
self:destroy()
|
|
653
669
|
end
|
|
654
670
|
end
|
|
671
|
+
if event.originalAmount ~= 0 then
|
|
672
|
+
local damageDealtEventCount = (self[130] or 0) + 1
|
|
673
|
+
self[130] = damageDealtEventCount
|
|
674
|
+
if damageDealtEventCount == self[131] then
|
|
675
|
+
self:destroy()
|
|
676
|
+
end
|
|
677
|
+
end
|
|
678
|
+
end
|
|
679
|
+
function Buff.prototype.onDamageReceived(self, source, event)
|
|
680
|
+
if event.originalAmount ~= 0 then
|
|
681
|
+
local damageReceivedEventCount = (self[132] or 0) + 1
|
|
682
|
+
self[132] = damageReceivedEventCount
|
|
683
|
+
if damageReceivedEventCount == self[133] then
|
|
684
|
+
self:destroy()
|
|
685
|
+
end
|
|
686
|
+
end
|
|
655
687
|
end
|
|
656
688
|
Buff.defaultParameters = {}
|
|
657
689
|
__TS__SetDescriptor(
|
|
@@ -887,25 +919,25 @@ __TS__SetDescriptor(
|
|
|
887
919
|
"stuns",
|
|
888
920
|
{
|
|
889
921
|
get = function(self)
|
|
890
|
-
local
|
|
891
|
-
if
|
|
892
|
-
|
|
922
|
+
local ____self__134_52 = self[134]
|
|
923
|
+
if ____self__134_52 == nil then
|
|
924
|
+
____self__134_52 = false
|
|
893
925
|
end
|
|
894
|
-
return
|
|
926
|
+
return ____self__134_52
|
|
895
927
|
end,
|
|
896
928
|
set = function(self, stuns)
|
|
897
|
-
if not stuns and self[
|
|
898
|
-
if self[
|
|
929
|
+
if not stuns and self[134] then
|
|
930
|
+
if self[135] then
|
|
899
931
|
self.object:decrementStunCounter()
|
|
900
932
|
end
|
|
901
933
|
self.object:decrementStunCounter()
|
|
902
|
-
self[
|
|
903
|
-
elseif stuns and not self[
|
|
904
|
-
if self[
|
|
934
|
+
self[134] = nil
|
|
935
|
+
elseif stuns and not self[134] then
|
|
936
|
+
if self[135] then
|
|
905
937
|
self.object:incrementStunCounter()
|
|
906
938
|
end
|
|
907
939
|
self.object:incrementStunCounter()
|
|
908
|
-
self[
|
|
940
|
+
self[134] = true
|
|
909
941
|
end
|
|
910
942
|
end
|
|
911
943
|
},
|
|
@@ -916,23 +948,23 @@ __TS__SetDescriptor(
|
|
|
916
948
|
"ignoresStunImmunity",
|
|
917
949
|
{
|
|
918
950
|
get = function(self)
|
|
919
|
-
local
|
|
920
|
-
if
|
|
921
|
-
|
|
951
|
+
local ____self__135_53 = self[135]
|
|
952
|
+
if ____self__135_53 == nil then
|
|
953
|
+
____self__135_53 = false
|
|
922
954
|
end
|
|
923
|
-
return
|
|
955
|
+
return ____self__135_53
|
|
924
956
|
end,
|
|
925
957
|
set = function(self, ignoresStunImmunity)
|
|
926
|
-
if not ignoresStunImmunity and self[
|
|
927
|
-
if self[
|
|
958
|
+
if not ignoresStunImmunity and self[135] then
|
|
959
|
+
if self[134] then
|
|
928
960
|
self.object:decrementStunCounter()
|
|
929
961
|
end
|
|
930
|
-
self[
|
|
931
|
-
elseif ignoresStunImmunity and not self[
|
|
932
|
-
if self[
|
|
962
|
+
self[135] = nil
|
|
963
|
+
elseif ignoresStunImmunity and not self[135] then
|
|
964
|
+
if self[134] then
|
|
933
965
|
self.object:incrementStunCounter()
|
|
934
966
|
end
|
|
935
|
-
self[
|
|
967
|
+
self[135] = true
|
|
936
968
|
end
|
|
937
969
|
end
|
|
938
970
|
},
|
|
@@ -943,19 +975,19 @@ __TS__SetDescriptor(
|
|
|
943
975
|
"disablesAutoAttack",
|
|
944
976
|
{
|
|
945
977
|
get = function(self)
|
|
946
|
-
local
|
|
947
|
-
if
|
|
948
|
-
|
|
978
|
+
local ____self__136_54 = self[136]
|
|
979
|
+
if ____self__136_54 == nil then
|
|
980
|
+
____self__136_54 = false
|
|
949
981
|
end
|
|
950
|
-
return
|
|
982
|
+
return ____self__136_54
|
|
951
983
|
end,
|
|
952
984
|
set = function(self, disablesAutoAttack)
|
|
953
|
-
if not disablesAutoAttack and self[
|
|
985
|
+
if not disablesAutoAttack and self[136] then
|
|
954
986
|
self.object:decrementDisableAutoAttackCounter()
|
|
955
|
-
self[
|
|
956
|
-
elseif disablesAutoAttack and not self[
|
|
987
|
+
self[136] = nil
|
|
988
|
+
elseif disablesAutoAttack and not self[136] then
|
|
957
989
|
self.object:incrementDisableAutoAttackCounter()
|
|
958
|
-
self[
|
|
990
|
+
self[136] = true
|
|
959
991
|
end
|
|
960
992
|
end
|
|
961
993
|
},
|
|
@@ -966,19 +998,19 @@ __TS__SetDescriptor(
|
|
|
966
998
|
"providesInvulnerability",
|
|
967
999
|
{
|
|
968
1000
|
get = function(self)
|
|
969
|
-
local
|
|
970
|
-
if
|
|
971
|
-
|
|
1001
|
+
local ____self__137_55 = self[137]
|
|
1002
|
+
if ____self__137_55 == nil then
|
|
1003
|
+
____self__137_55 = false
|
|
972
1004
|
end
|
|
973
|
-
return
|
|
1005
|
+
return ____self__137_55
|
|
974
1006
|
end,
|
|
975
1007
|
set = function(self, providesInvulnerability)
|
|
976
|
-
if not providesInvulnerability and self[
|
|
1008
|
+
if not providesInvulnerability and self[137] then
|
|
977
1009
|
self.object:decrementInvulnerabilityCounter()
|
|
978
|
-
self[
|
|
979
|
-
elseif providesInvulnerability and not self[
|
|
1010
|
+
self[137] = nil
|
|
1011
|
+
elseif providesInvulnerability and not self[137] then
|
|
980
1012
|
self.object:incrementInvulnerabilityCounter()
|
|
981
|
-
self[
|
|
1013
|
+
self[137] = true
|
|
982
1014
|
end
|
|
983
1015
|
end
|
|
984
1016
|
},
|
|
@@ -989,17 +1021,17 @@ __TS__SetDescriptor(
|
|
|
989
1021
|
"killsOnExpiration",
|
|
990
1022
|
{
|
|
991
1023
|
get = function(self)
|
|
992
|
-
local
|
|
993
|
-
if
|
|
994
|
-
|
|
1024
|
+
local ____self__138_56 = self[138]
|
|
1025
|
+
if ____self__138_56 == nil then
|
|
1026
|
+
____self__138_56 = false
|
|
995
1027
|
end
|
|
996
|
-
return
|
|
1028
|
+
return ____self__138_56
|
|
997
1029
|
end,
|
|
998
1030
|
set = function(self, killsOnExpiration)
|
|
999
|
-
if not killsOnExpiration and self[
|
|
1000
|
-
self[
|
|
1001
|
-
elseif killsOnExpiration and not self[
|
|
1002
|
-
self[
|
|
1031
|
+
if not killsOnExpiration and self[138] then
|
|
1032
|
+
self[138] = nil
|
|
1033
|
+
elseif killsOnExpiration and not self[138] then
|
|
1034
|
+
self[138] = true
|
|
1003
1035
|
end
|
|
1004
1036
|
end
|
|
1005
1037
|
},
|
|
@@ -1010,17 +1042,51 @@ __TS__SetDescriptor(
|
|
|
1010
1042
|
"explodesOnExpiration",
|
|
1011
1043
|
{
|
|
1012
1044
|
get = function(self)
|
|
1013
|
-
local
|
|
1014
|
-
if
|
|
1015
|
-
|
|
1045
|
+
local ____self__139_57 = self[139]
|
|
1046
|
+
if ____self__139_57 == nil then
|
|
1047
|
+
____self__139_57 = false
|
|
1016
1048
|
end
|
|
1017
|
-
return
|
|
1049
|
+
return ____self__139_57
|
|
1018
1050
|
end,
|
|
1019
1051
|
set = function(self, killsOnExpiration)
|
|
1020
|
-
if not killsOnExpiration and self[
|
|
1021
|
-
self[
|
|
1022
|
-
elseif killsOnExpiration and not self[
|
|
1023
|
-
self[
|
|
1052
|
+
if not killsOnExpiration and self[139] then
|
|
1053
|
+
self[139] = nil
|
|
1054
|
+
elseif killsOnExpiration and not self[139] then
|
|
1055
|
+
self[139] = true
|
|
1056
|
+
end
|
|
1057
|
+
end
|
|
1058
|
+
},
|
|
1059
|
+
true
|
|
1060
|
+
)
|
|
1061
|
+
__TS__SetDescriptor(
|
|
1062
|
+
Buff.prototype,
|
|
1063
|
+
"maximumDamageDealtEventCount",
|
|
1064
|
+
{
|
|
1065
|
+
get = function(self)
|
|
1066
|
+
return self[131] or 0
|
|
1067
|
+
end,
|
|
1068
|
+
set = function(self, maximumDamageDealtEventCount)
|
|
1069
|
+
if maximumDamageDealtEventCount == 0 then
|
|
1070
|
+
self[131] = nil
|
|
1071
|
+
else
|
|
1072
|
+
self[131] = maximumDamageDealtEventCount
|
|
1073
|
+
end
|
|
1074
|
+
end
|
|
1075
|
+
},
|
|
1076
|
+
true
|
|
1077
|
+
)
|
|
1078
|
+
__TS__SetDescriptor(
|
|
1079
|
+
Buff.prototype,
|
|
1080
|
+
"maximumDamageReceivedEventCount",
|
|
1081
|
+
{
|
|
1082
|
+
get = function(self)
|
|
1083
|
+
return self[133] or 0
|
|
1084
|
+
end,
|
|
1085
|
+
set = function(self, maximumDamageReceivedEventCount)
|
|
1086
|
+
if maximumDamageReceivedEventCount == 0 then
|
|
1087
|
+
self[133] = nil
|
|
1088
|
+
else
|
|
1089
|
+
self[133] = maximumDamageReceivedEventCount
|
|
1024
1090
|
end
|
|
1025
1091
|
end
|
|
1026
1092
|
},
|
|
@@ -42,6 +42,7 @@ export interface DamagingEvent {
|
|
|
42
42
|
damageType: jdamagetype;
|
|
43
43
|
weaponType: jweapontype;
|
|
44
44
|
readonly isAttack: boolean;
|
|
45
|
+
readonly originalAmount: number;
|
|
45
46
|
}
|
|
46
47
|
export type DamageEvent = DamagingEvent & {
|
|
47
48
|
preventDeath<P extends any[]>(this: DamageEvent, callback: (this: void, ...parameters: P) => any, ...parameters: P): void;
|
package/engine/internal/unit.lua
CHANGED
|
@@ -2452,6 +2452,7 @@ Unit.onDamage = __TS__New(
|
|
|
2452
2452
|
damageType = BlzGetEventDamageType(),
|
|
2453
2453
|
weaponType = BlzGetEventWeaponType(),
|
|
2454
2454
|
isAttack = BlzGetEventIsAttack(),
|
|
2455
|
+
originalAmount = GetEventDamage(),
|
|
2455
2456
|
preventDeath = damageEventPreventDeath
|
|
2456
2457
|
}
|
|
2457
2458
|
local evData = setmetatable(
|
|
@@ -6,6 +6,9 @@ import { ObjectDataEntryId } from "../object-data/entry";
|
|
|
6
6
|
import { LightningTypeId } from "../object-data/entry/lightning-type";
|
|
7
7
|
import { CombatClassifications } from "../object-data/auxiliary/combat-classification";
|
|
8
8
|
import { UnitTypeId } from "../object-data/entry/unit-type";
|
|
9
|
+
import { BuffResistanceType } from "../object-data/auxiliary/buff-resistance-type";
|
|
10
|
+
import { BuffPolarity } from "../object-data/auxiliary/buff-polarity";
|
|
11
|
+
import { ReadonlyNonEmptyLinkedSet } from "../../utility/linked-set";
|
|
9
12
|
export declare abstract class AbilityField<ValueType extends number | string | boolean = number | string | boolean, NativeFieldType extends jabilityfield = jabilityfield> extends ObjectField<AbilityType, Ability, ValueType, NativeFieldType> {
|
|
10
13
|
protected get instanceClass(): typeof Ability;
|
|
11
14
|
protected getObjectDataEntryId(instance: Ability): AbilityTypeId;
|
|
@@ -107,6 +110,20 @@ export declare class AbilityAbilityTypeIdLevelField extends AbilityObjectDataEnt
|
|
|
107
110
|
}
|
|
108
111
|
export declare class AbilityUnitTypeIdLevelField extends AbilityObjectDataEntryIdLevelField<UnitTypeId> {
|
|
109
112
|
}
|
|
113
|
+
export declare abstract class AbilityEnumLevelField<T extends number> extends AbilityLevelField<T, T, jabilityintegerlevelfield> {
|
|
114
|
+
protected abstract values: ReadonlyNonEmptyLinkedSet<T>;
|
|
115
|
+
protected get defaultValue(): T;
|
|
116
|
+
protected getNativeFieldById(id: number): jabilityintegerlevelfield;
|
|
117
|
+
protected getNativeFieldValue(instance: Ability, level: number): T;
|
|
118
|
+
protected setNativeFieldValue(instance: Ability, level: number, value: T): boolean;
|
|
119
|
+
static get valueChangeEvent(): ObjectLevelFieldValueChangeEvent<AbilityBooleanLevelField>;
|
|
120
|
+
}
|
|
121
|
+
export declare class AbilityBuffPolarityLevelField extends AbilityEnumLevelField<BuffPolarity> {
|
|
122
|
+
protected values: ReadonlyNonEmptyLinkedSet<BuffPolarity>;
|
|
123
|
+
}
|
|
124
|
+
export declare class AbilityBuffResistanceTypeLevelField extends AbilityEnumLevelField<BuffResistanceType> {
|
|
125
|
+
protected values: ReadonlyNonEmptyLinkedSet<BuffResistanceType>;
|
|
126
|
+
}
|
|
110
127
|
export declare class AbilityCombatClassificationsLevelField extends AbilityLevelField<CombatClassifications, CombatClassifications, jabilityintegerlevelfield> {
|
|
111
128
|
protected get defaultValue(): CombatClassifications;
|
|
112
129
|
protected getNativeFieldById(id: number): jabilityintegerlevelfield;
|
|
@@ -13,6 +13,8 @@ local ObjectField = ____object_2Dfield.ObjectField
|
|
|
13
13
|
local ObjectLevelField = ____object_2Dfield.ObjectLevelField
|
|
14
14
|
local ____ability_2Dtype = require("engine.object-data.entry.ability-type")
|
|
15
15
|
local AbilityType = ____ability_2Dtype.AbilityType
|
|
16
|
+
local ____linked_2Dset = require("utility.linked-set")
|
|
17
|
+
local nonEmptyLinkedSetOf = ____linked_2Dset.nonEmptyLinkedSetOf
|
|
16
18
|
local convertAbilityBooleanField = _G.ConvertAbilityBooleanField
|
|
17
19
|
local convertAbilityIntegerField = _G.ConvertAbilityIntegerField
|
|
18
20
|
local convertAbilityRealField = _G.ConvertAbilityRealField
|
|
@@ -431,6 +433,54 @@ ____exports.AbilityUnitTypeIdLevelField = __TS__Class()
|
|
|
431
433
|
local AbilityUnitTypeIdLevelField = ____exports.AbilityUnitTypeIdLevelField
|
|
432
434
|
AbilityUnitTypeIdLevelField.name = "AbilityUnitTypeIdLevelField"
|
|
433
435
|
__TS__ClassExtends(AbilityUnitTypeIdLevelField, ____exports.AbilityObjectDataEntryIdLevelField)
|
|
436
|
+
____exports.AbilityEnumLevelField = __TS__Class()
|
|
437
|
+
local AbilityEnumLevelField = ____exports.AbilityEnumLevelField
|
|
438
|
+
AbilityEnumLevelField.name = "AbilityEnumLevelField"
|
|
439
|
+
__TS__ClassExtends(AbilityEnumLevelField, ____exports.AbilityLevelField)
|
|
440
|
+
function AbilityEnumLevelField.prototype.getNativeFieldById(self, id)
|
|
441
|
+
return convertAbilityIntegerLevelField(id)
|
|
442
|
+
end
|
|
443
|
+
function AbilityEnumLevelField.prototype.getNativeFieldValue(self, instance, level)
|
|
444
|
+
local value = instance:getField(self.nativeField, level)
|
|
445
|
+
if self.values:contains(value) then
|
|
446
|
+
return value
|
|
447
|
+
end
|
|
448
|
+
return self.values:first()
|
|
449
|
+
end
|
|
450
|
+
function AbilityEnumLevelField.prototype.setNativeFieldValue(self, instance, level, value)
|
|
451
|
+
return instance:setField(self.nativeField, level, value)
|
|
452
|
+
end
|
|
453
|
+
__TS__SetDescriptor(
|
|
454
|
+
AbilityEnumLevelField.prototype,
|
|
455
|
+
"defaultValue",
|
|
456
|
+
{get = function(self)
|
|
457
|
+
return self.values:first()
|
|
458
|
+
end},
|
|
459
|
+
true
|
|
460
|
+
)
|
|
461
|
+
__TS__ObjectDefineProperty(
|
|
462
|
+
AbilityEnumLevelField,
|
|
463
|
+
"valueChangeEvent",
|
|
464
|
+
{get = function(self)
|
|
465
|
+
return self:getOrCreateValueChangeEvent()
|
|
466
|
+
end}
|
|
467
|
+
)
|
|
468
|
+
____exports.AbilityBuffPolarityLevelField = __TS__Class()
|
|
469
|
+
local AbilityBuffPolarityLevelField = ____exports.AbilityBuffPolarityLevelField
|
|
470
|
+
AbilityBuffPolarityLevelField.name = "AbilityBuffPolarityLevelField"
|
|
471
|
+
__TS__ClassExtends(AbilityBuffPolarityLevelField, ____exports.AbilityEnumLevelField)
|
|
472
|
+
function AbilityBuffPolarityLevelField.prototype.____constructor(self, ...)
|
|
473
|
+
AbilityBuffPolarityLevelField.____super.prototype.____constructor(self, ...)
|
|
474
|
+
self.values = nonEmptyLinkedSetOf(0, 1, 2)
|
|
475
|
+
end
|
|
476
|
+
____exports.AbilityBuffResistanceTypeLevelField = __TS__Class()
|
|
477
|
+
local AbilityBuffResistanceTypeLevelField = ____exports.AbilityBuffResistanceTypeLevelField
|
|
478
|
+
AbilityBuffResistanceTypeLevelField.name = "AbilityBuffResistanceTypeLevelField"
|
|
479
|
+
__TS__ClassExtends(AbilityBuffResistanceTypeLevelField, ____exports.AbilityEnumLevelField)
|
|
480
|
+
function AbilityBuffResistanceTypeLevelField.prototype.____constructor(self, ...)
|
|
481
|
+
AbilityBuffResistanceTypeLevelField.____super.prototype.____constructor(self, ...)
|
|
482
|
+
self.values = nonEmptyLinkedSetOf(1, 2, 3)
|
|
483
|
+
end
|
|
434
484
|
local allowedTargetCombatClassificationsByLevelByAbilityTypeId = postcompile(function()
|
|
435
485
|
local allowedTargetCombatClassificationsByLevelByAbilityTypeId = {}
|
|
436
486
|
for ____, abilityType in ipairs(AbilityType:getAll()) do
|
package/package.json
CHANGED
package/utility/linked-set.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
|
+
import { NonEmptyArray, ReadonlyNonEmptyArray } from "./types";
|
|
2
3
|
type IteratorState<T extends AnyNotNil> = {
|
|
3
4
|
t: LuaMap<T, T>;
|
|
4
5
|
n?: T;
|
|
@@ -18,6 +19,11 @@ export interface ReadonlyLinkedSet<T extends AnyNotNil> extends LuaPairsKeyItera
|
|
|
18
19
|
toArray(): T[];
|
|
19
20
|
sumOf(selector: ((value: T) => number) | KeysOfType<T, number>): number;
|
|
20
21
|
}
|
|
22
|
+
export interface ReadonlyNonEmptyLinkedSet<T extends AnyNotNil> extends ReadonlyLinkedSet<T> {
|
|
23
|
+
first(): T;
|
|
24
|
+
last(): T;
|
|
25
|
+
toArray(): NonEmptyArray<T>;
|
|
26
|
+
}
|
|
21
27
|
export interface LinkedSet<T extends AnyNotNil> extends LuaPairsKeyIterable<T> {
|
|
22
28
|
readonly __linkedSet: unique symbol;
|
|
23
29
|
}
|
|
@@ -44,6 +50,9 @@ export declare class LinkedSet<T extends AnyNotNil> implements ReadonlyLinkedSet
|
|
|
44
50
|
protected __pairs(this: LinkedSet<T>): LuaIterator<T | undefined, IteratorState<T>>;
|
|
45
51
|
}
|
|
46
52
|
export declare const emptyLinkedSet: <T extends AnyNotNil>() => ReadonlyLinkedSet<T>;
|
|
47
|
-
export declare const
|
|
48
|
-
export declare const
|
|
53
|
+
export declare const mutableLinkedSetOf: <T extends AnyNotNil>(...elements: ReadonlyArray<T>) => LinkedSet<T>;
|
|
54
|
+
export declare const mutableLinkedSetOfNotNull: <T extends AnyNotNil>(...elements: readonly (T | undefined | null)[]) => LinkedSet<T>;
|
|
55
|
+
export declare const linkedSetOf: <T extends AnyNotNil>(...elements: ReadonlyArray<T>) => ReadonlyLinkedSet<T>;
|
|
56
|
+
export declare const linkedSetOfNotNull: <T extends AnyNotNil>(...elements: ReadonlyArray<T>) => ReadonlyLinkedSet<T>;
|
|
57
|
+
export declare const nonEmptyLinkedSetOf: <T extends AnyNotNil>(...elements: ReadonlyNonEmptyArray<T>) => ReadonlyNonEmptyLinkedSet<T>;
|
|
49
58
|
export {};
|
package/utility/linked-set.lua
CHANGED
|
@@ -177,14 +177,14 @@ local EMPTY_LINKED_SET = __TS__New(EmptyLinkedSet)
|
|
|
177
177
|
____exports.emptyLinkedSet = function()
|
|
178
178
|
return EMPTY_LINKED_SET
|
|
179
179
|
end
|
|
180
|
-
____exports.
|
|
180
|
+
____exports.mutableLinkedSetOf = function(...)
|
|
181
181
|
local linkedSet = __TS__New(____exports.LinkedSet)
|
|
182
182
|
for i = 1, select("#", ...) do
|
|
183
183
|
linkedSet:add((select(i, ...)))
|
|
184
184
|
end
|
|
185
185
|
return linkedSet
|
|
186
186
|
end
|
|
187
|
-
____exports.
|
|
187
|
+
____exports.mutableLinkedSetOfNotNull = function(...)
|
|
188
188
|
local linkedSet = __TS__New(____exports.LinkedSet)
|
|
189
189
|
for i = 1, select("#", ...) do
|
|
190
190
|
local element = (select(i, ...))
|
|
@@ -194,4 +194,7 @@ ____exports.linkedSetOfNotNull = function(...)
|
|
|
194
194
|
end
|
|
195
195
|
return linkedSet
|
|
196
196
|
end
|
|
197
|
+
____exports.linkedSetOf = function(...) return ____exports.mutableLinkedSetOf(...) end
|
|
198
|
+
____exports.linkedSetOfNotNull = function(...) return ____exports.mutableLinkedSetOfNotNull(...) end
|
|
199
|
+
____exports.nonEmptyLinkedSetOf = function(...) return ____exports.linkedSetOf(...) end
|
|
197
200
|
return ____exports
|
package/utility/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export type AnyNonNullable = {};
|
|
3
3
|
export type IsExactlyAny<T> = boolean extends (T extends never ? true : false) ? true : false;
|
|
4
4
|
export type NonEmptyArray<T> = [T, ...T[]];
|
|
5
|
+
export type ReadonlyNonEmptyArray<T> = readonly [T, ...T[]];
|
|
5
6
|
export type InvertRecordType<T extends Record<PropertyKey, PropertyKey | null | undefined>> = {
|
|
6
7
|
[P in keyof T as NonNullable<T[P]>]: P;
|
|
7
8
|
};
|