warscript 0.0.1-dev.4363c65 → 0.0.1-dev.56d888d
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 +11 -5
- package/engine/buff.lua +17 -2
- package/engine/internal/unit/bonus.d.ts +4 -2
- package/engine/internal/unit/bonus.lua +6 -1
- package/engine/internal/unit.d.ts +1 -0
- package/engine/internal/unit.lua +1 -0
- package/package.json +1 -1
|
@@ -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 ? {
|
|
@@ -51,6 +54,7 @@ export type BuffParameters<T extends Buff<any> = Buff> = Buff extends T ? {
|
|
|
51
54
|
armorIncreaseFactor?: NumberParameterValueType;
|
|
52
55
|
attackSpeedIncreaseFactor?: NumberParameterValueType;
|
|
53
56
|
movementSpeedIncreaseFactor?: NumberParameterValueType;
|
|
57
|
+
damageFactor?: NumberParameterValueType;
|
|
54
58
|
receivedDamageFactor?: NumberParameterValueType;
|
|
55
59
|
receivedMagicDamageFactor?: NumberParameterValueType;
|
|
56
60
|
durationIncreaseOnAutoAttack?: NumberParameterValueType;
|
|
@@ -120,11 +124,11 @@ export declare const enum BuffTypeIdSelectionPolicy {
|
|
|
120
124
|
export type BuffAdditionalParameters = Prohibit<Record<string, any>, keyof BuffParameters>;
|
|
121
125
|
export type BuffConstructorParameters<AdditionalParameters extends BuffAdditionalParameters> = [
|
|
122
126
|
...typeId: [ApplicableBuffTypeId] | [
|
|
123
|
-
typeIds:
|
|
127
|
+
typeIds: ReadonlyNonEmptyArray<ApplicableBuffTypeId>,
|
|
124
128
|
typeIdSelectionPolicy: BuffTypeIdSelectionPolicy
|
|
125
129
|
],
|
|
126
|
-
polarity:
|
|
127
|
-
resistanceType:
|
|
130
|
+
polarity: BuffPolarityParameterType,
|
|
131
|
+
resistanceType: BuffResistanceTypeParameterType,
|
|
128
132
|
...abilityOrParameters: [
|
|
129
133
|
ability: Ability,
|
|
130
134
|
parameters?: BuffParameters & Omit<AdditionalParameters, keyof BuffParameters>
|
|
@@ -213,6 +217,8 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
|
|
|
213
217
|
set damageOnExpiration(damageOnExpiration: number);
|
|
214
218
|
get healingOnExpiration(): number;
|
|
215
219
|
set healingOnExpiration(healingOnExpiration: number);
|
|
220
|
+
get damageFactor(): number;
|
|
221
|
+
set damageFactor(damageFactor: number);
|
|
216
222
|
get receivedDamageFactor(): number;
|
|
217
223
|
set receivedDamageFactor(receivedDamageFactor: number);
|
|
218
224
|
get armorIncrease(): number;
|
package/engine/buff.lua
CHANGED
|
@@ -94,6 +94,7 @@ local buffParametersKeys = {
|
|
|
94
94
|
armorIncreaseFactor = true,
|
|
95
95
|
attackSpeedIncreaseFactor = true,
|
|
96
96
|
movementSpeedIncreaseFactor = true,
|
|
97
|
+
damageFactor = true,
|
|
97
98
|
receivedDamageFactor = true,
|
|
98
99
|
receivedMagicDamageFactor = true,
|
|
99
100
|
durationIncreaseOnAutoAttack = true,
|
|
@@ -176,6 +177,7 @@ local buffNumberParameters = {
|
|
|
176
177
|
"attackSpeedIncreaseFactor",
|
|
177
178
|
"movementSpeedIncreaseFactor",
|
|
178
179
|
"armorIncrease",
|
|
180
|
+
"damageFactor",
|
|
179
181
|
"receivedDamageFactor",
|
|
180
182
|
"maximumAutoAttackCount",
|
|
181
183
|
"maximumDamageDealtEventCount",
|
|
@@ -668,7 +670,7 @@ function Buff.prototype.onDamageDealt(self, target, event)
|
|
|
668
670
|
self:destroy()
|
|
669
671
|
end
|
|
670
672
|
end
|
|
671
|
-
if event.
|
|
673
|
+
if event.originalAmount ~= 0 then
|
|
672
674
|
local damageDealtEventCount = (self[130] or 0) + 1
|
|
673
675
|
self[130] = damageDealtEventCount
|
|
674
676
|
if damageDealtEventCount == self[131] then
|
|
@@ -677,7 +679,7 @@ function Buff.prototype.onDamageDealt(self, target, event)
|
|
|
677
679
|
end
|
|
678
680
|
end
|
|
679
681
|
function Buff.prototype.onDamageReceived(self, source, event)
|
|
680
|
-
if event.
|
|
682
|
+
if event.originalAmount ~= 0 then
|
|
681
683
|
local damageReceivedEventCount = (self[132] or 0) + 1
|
|
682
684
|
self[132] = damageReceivedEventCount
|
|
683
685
|
if damageReceivedEventCount == self[133] then
|
|
@@ -888,6 +890,19 @@ __TS__SetDescriptor(
|
|
|
888
890
|
},
|
|
889
891
|
true
|
|
890
892
|
)
|
|
893
|
+
__TS__SetDescriptor(
|
|
894
|
+
Buff.prototype,
|
|
895
|
+
"damageFactor",
|
|
896
|
+
{
|
|
897
|
+
get = function(self)
|
|
898
|
+
return self:getUnitBonus(UnitBonusType.DAMAGE_FACTOR)
|
|
899
|
+
end,
|
|
900
|
+
set = function(self, damageFactor)
|
|
901
|
+
self:addOrUpdateOrRemoveUnitBonus(UnitBonusType.DAMAGE_FACTOR, damageFactor)
|
|
902
|
+
end
|
|
903
|
+
},
|
|
904
|
+
true
|
|
905
|
+
)
|
|
891
906
|
__TS__SetDescriptor(
|
|
892
907
|
Buff.prototype,
|
|
893
908
|
"receivedDamageFactor",
|
|
@@ -8,7 +8,8 @@ export type UnitBonusId<Brand extends string = any> = number & {
|
|
|
8
8
|
export type UnitArmorBonusId = UnitBonusId<"armor">;
|
|
9
9
|
export type UnitAttackSpeedFactorBonusId = UnitBonusId<"attackSpeedFactor">;
|
|
10
10
|
export type UnitMovementSpeedFactorBonusId = UnitBonusId<"movementSpeedFactor">;
|
|
11
|
-
export type
|
|
11
|
+
export type UnitAutoAttackDamageBonusId = UnitBonusId<"autoAttackDamage">;
|
|
12
|
+
export type UnitDamageFactorBonusId = UnitBonusId<"damageFactor">;
|
|
12
13
|
export type UnitReceivedDamageFactorBonusId = UnitBonusId<"receivedDamageFactor">;
|
|
13
14
|
export type UnitBonusType<Id extends UnitBonusId = UnitBonusId> = ({
|
|
14
15
|
abilityTypeId: AbilityTypeId;
|
|
@@ -30,7 +31,8 @@ export declare namespace UnitBonusType {
|
|
|
30
31
|
const ARMOR: UnitBonusType<UnitArmorBonusId>;
|
|
31
32
|
const ATTACK_SPEED_FACTOR: UnitBonusType<UnitAttackSpeedFactorBonusId>;
|
|
32
33
|
const MOVEMENT_SPEED_FACTOR: UnitBonusType<UnitAttackSpeedFactorBonusId>;
|
|
33
|
-
const
|
|
34
|
+
const AUTO_ATTACK_DAMAGE: UnitBonusType<UnitAutoAttackDamageBonusId>;
|
|
35
|
+
const DAMAGE_FACTOR: UnitBonusType<UnitReceivedDamageFactorBonusId>;
|
|
34
36
|
const RECEIVED_DAMAGE_FACTOR: UnitBonusType<UnitReceivedDamageFactorBonusId>;
|
|
35
37
|
}
|
|
36
38
|
export declare const addUnitBonus: <Id extends UnitBonusId>(unit: Unit, bonusType: UnitBonusType<Id>, value: number) => Id;
|
|
@@ -21,6 +21,7 @@ local AUTO_ATTACK_DAMAGE_INCREASE_DUMMY_ABILITY_TYPE_ID = ____auto_2Dattack_2Dda
|
|
|
21
21
|
local ____movement_2Dspeed_2Dincrease_2Dfactor = require("engine.internal.object-data.movement-speed-increase-factor")
|
|
22
22
|
local MOVEMENT_SPEED_INCREASE_FACTOR_ABILITY_FIELD = ____movement_2Dspeed_2Dincrease_2Dfactor.MOVEMENT_SPEED_INCREASE_FACTOR_ABILITY_FIELD
|
|
23
23
|
local MOVEMENT_SPEED_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID = ____movement_2Dspeed_2Dincrease_2Dfactor.MOVEMENT_SPEED_INCREASE_FACTOR_DUMMY_ABILITY_TYPE_ID
|
|
24
|
+
local damageFactorByUnit = {}
|
|
24
25
|
local receivedDamageFactorByUnit = {}
|
|
25
26
|
____exports.UnitBonusType = {}
|
|
26
27
|
local UnitBonusType = ____exports.UnitBonusType
|
|
@@ -46,13 +47,14 @@ do
|
|
|
46
47
|
reduce = sum,
|
|
47
48
|
initialValue = 0
|
|
48
49
|
}
|
|
49
|
-
UnitBonusType.
|
|
50
|
+
UnitBonusType.AUTO_ATTACK_DAMAGE = {
|
|
50
51
|
abilityTypeId = AUTO_ATTACK_DAMAGE_INCREASE_DUMMY_ABILITY_TYPE_ID,
|
|
51
52
|
field = AUTO_ATTACK_DAMAGE_INCREASE_ABILITY_FIELD,
|
|
52
53
|
integer = false,
|
|
53
54
|
reduce = sum,
|
|
54
55
|
initialValue = 0
|
|
55
56
|
}
|
|
57
|
+
UnitBonusType.DAMAGE_FACTOR = {reduce = product, valueByUnit = damageFactorByUnit, initialValue = 1}
|
|
56
58
|
UnitBonusType.RECEIVED_DAMAGE_FACTOR = {reduce = product, valueByUnit = receivedDamageFactorByUnit, initialValue = 1}
|
|
57
59
|
end
|
|
58
60
|
local bonusesByUnitByBonusType = {}
|
|
@@ -180,6 +182,9 @@ end
|
|
|
180
182
|
Unit.onDamage:addListener(
|
|
181
183
|
4,
|
|
182
184
|
function(source, target, event)
|
|
185
|
+
if source ~= nil and damageFactorByUnit[source] ~= nil then
|
|
186
|
+
event.amount = event.amount * damageFactorByUnit[source]
|
|
187
|
+
end
|
|
183
188
|
if receivedDamageFactorByUnit[target] ~= nil then
|
|
184
189
|
event.amount = event.amount * receivedDamageFactorByUnit[target]
|
|
185
190
|
end
|
|
@@ -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(
|
package/package.json
CHANGED