warscript 0.0.1-dev.07e3832 → 0.0.1-dev.0e6c999
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/binaryreader.d.ts +1 -0
- package/binaryreader.lua +3 -0
- package/engine/behaviour/ability/damage.d.ts +25 -21
- package/engine/behaviour/ability/damage.lua +54 -55
- package/engine/behaviour/ability/heal.d.ts +33 -6
- package/engine/behaviour/ability/heal.lua +89 -10
- package/engine/buff.d.ts +34 -13
- package/engine/buff.lua +154 -58
- package/package.json +2 -2
- package/property.d.ts +55 -0
- package/property.lua +374 -0
package/binaryreader.d.ts
CHANGED
package/binaryreader.lua
CHANGED
|
@@ -9,6 +9,9 @@ function BinaryReader.prototype.____constructor(self, data)
|
|
|
9
9
|
self.i = 1
|
|
10
10
|
self.s = data
|
|
11
11
|
end
|
|
12
|
+
function BinaryReader.prototype.__tostring(self)
|
|
13
|
+
return self.s
|
|
14
|
+
end
|
|
12
15
|
function BinaryReader.prototype.read(self, fmt)
|
|
13
16
|
local value, pos = ____unpack(">" .. fmt, self.s, self.i)
|
|
14
17
|
self.i = pos
|
|
@@ -5,37 +5,41 @@ import { Unit } from "../../internal/unit";
|
|
|
5
5
|
import { AbilityDependentValue } from "../../object-field/ability";
|
|
6
6
|
import { Widget } from "../../../core/types/widget";
|
|
7
7
|
import { AttackType, DamageType, WeaponType } from "../../internal/unit+damage";
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
export type DamageAbilityBehaviorParameters = {
|
|
9
|
+
damagePerStrength?: AbilityDependentValue<number>;
|
|
10
|
+
damagePerAgility?: AbilityDependentValue<number>;
|
|
11
|
+
damagePerIntelligence?: AbilityDependentValue<number>;
|
|
12
|
+
attackType?: AttackType;
|
|
13
|
+
damageType?: DamageType;
|
|
14
|
+
weaponType?: WeaponType;
|
|
15
|
+
};
|
|
16
|
+
export type DamageAreaAbilityBehaviorParameters = DamageAbilityBehaviorParameters & {
|
|
17
|
+
maximumDamage?: AbilityDependentValue<number>;
|
|
18
|
+
};
|
|
19
|
+
declare abstract class DamageAbilityBehavior<T extends DamageAbilityBehaviorParameters = DamageAbilityBehaviorParameters> extends AbilityBehavior {
|
|
20
|
+
protected readonly damage: AbilityDependentValue<number>;
|
|
21
|
+
protected readonly parameters?: T | undefined;
|
|
22
|
+
protected constructor(ability: Ability, damage: AbilityDependentValue<number>, parameters?: T | undefined);
|
|
23
|
+
protected calculateDamage(caster: Unit): number;
|
|
24
|
+
}
|
|
25
|
+
export declare class DamageSelfAbilityBehavior extends DamageAbilityBehavior {
|
|
26
|
+
constructor(ability: Ability, damage: AbilityDependentValue<number>, parameters?: DamageAbilityBehaviorParameters);
|
|
14
27
|
onImpact(caster: Unit): void;
|
|
15
28
|
}
|
|
16
|
-
export declare class DamageTargetAbilityBehavior extends
|
|
17
|
-
|
|
18
|
-
private readonly attackType?;
|
|
19
|
-
private readonly damageType?;
|
|
20
|
-
private readonly weaponType?;
|
|
21
|
-
constructor(ability: Ability, damage: AbilityDependentValue<number>, attackType?: AttackType | undefined, damageType?: DamageType | undefined, weaponType?: WeaponType | undefined);
|
|
29
|
+
export declare class DamageTargetAbilityBehavior extends DamageAbilityBehavior {
|
|
30
|
+
constructor(ability: Ability, damage: AbilityDependentValue<number>, parameters?: DamageAbilityBehaviorParameters);
|
|
22
31
|
onWidgetTargetImpact(caster: Unit, target: Widget): void;
|
|
23
32
|
}
|
|
24
|
-
declare abstract class DamageAreaAbilityBehavior extends
|
|
25
|
-
|
|
26
|
-
private readonly maximumDamage?;
|
|
27
|
-
private readonly attackType?;
|
|
28
|
-
private readonly damageType?;
|
|
29
|
-
private readonly weaponType?;
|
|
30
|
-
protected constructor(ability: Ability, damage: AbilityDependentValue<number>, maximumDamage?: AbilityDependentValue<number> | undefined, attackType?: AttackType | undefined, damageType?: DamageType | undefined, weaponType?: WeaponType | undefined);
|
|
33
|
+
declare abstract class DamageAreaAbilityBehavior extends DamageAbilityBehavior<DamageAreaAbilityBehaviorParameters> {
|
|
34
|
+
protected constructor(ability: Ability, damage: AbilityDependentValue<number>, parameters?: DamageAreaAbilityBehaviorParameters);
|
|
31
35
|
protected damageArea(caster: Unit, x: number, y: number): void;
|
|
32
36
|
}
|
|
33
37
|
export declare class DamageSelfAreaAbilityBehavior extends DamageAreaAbilityBehavior {
|
|
34
|
-
constructor(ability: Ability, damage: AbilityDependentValue<number>,
|
|
38
|
+
constructor(ability: Ability, damage: AbilityDependentValue<number>, parameters?: DamageAreaAbilityBehaviorParameters);
|
|
35
39
|
onImpact(caster: Unit): void;
|
|
36
40
|
}
|
|
37
41
|
export declare class DamageTargetAreaAbilityBehavior extends DamageAreaAbilityBehavior {
|
|
38
|
-
constructor(ability: Ability, damage: AbilityDependentValue<number>,
|
|
42
|
+
constructor(ability: Ability, damage: AbilityDependentValue<number>, parameters?: DamageAreaAbilityBehaviorParameters);
|
|
39
43
|
onNoTargetImpact(caster: Unit): void;
|
|
40
44
|
onWidgetTargetImpact(caster: Unit, target: Widget): void;
|
|
41
45
|
onPointTargetImpact(caster: Unit, x: number, y: number): void;
|
|
@@ -9,62 +9,77 @@ local Unit = ____unit.Unit
|
|
|
9
9
|
local ____ability = require("engine.standard.fields.ability")
|
|
10
10
|
local ALLOWED_TARGETS_ABILITY_COMBAT_CLASSIFICATIONS_LEVEL_FIELD = ____ability.ALLOWED_TARGETS_ABILITY_COMBAT_CLASSIFICATIONS_LEVEL_FIELD
|
|
11
11
|
local AREA_OF_EFFECT_ABILITY_FLOAT_LEVEL_FIELD = ____ability.AREA_OF_EFFECT_ABILITY_FLOAT_LEVEL_FIELD
|
|
12
|
+
local DamageAbilityBehavior = __TS__Class()
|
|
13
|
+
DamageAbilityBehavior.name = "DamageAbilityBehavior"
|
|
14
|
+
__TS__ClassExtends(DamageAbilityBehavior, AbilityBehavior)
|
|
15
|
+
function DamageAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
|
|
16
|
+
AbilityBehavior.prototype.____constructor(self, ability)
|
|
17
|
+
self.damage = damage
|
|
18
|
+
self.parameters = parameters
|
|
19
|
+
end
|
|
20
|
+
function DamageAbilityBehavior.prototype.calculateDamage(self, caster)
|
|
21
|
+
local parameters = self.parameters
|
|
22
|
+
local damage = self:resolveCurrentAbilityDependentValue(self.damage)
|
|
23
|
+
local damagePerStrength = self:resolveCurrentAbilityDependentValue(parameters and parameters.damagePerStrength or 0)
|
|
24
|
+
if damagePerStrength ~= 0 then
|
|
25
|
+
damage = damage + damagePerStrength * caster.strength
|
|
26
|
+
end
|
|
27
|
+
local damagePerAgility = self:resolveCurrentAbilityDependentValue(parameters and parameters.damagePerAgility or 0)
|
|
28
|
+
if damagePerAgility ~= 0 then
|
|
29
|
+
damage = damage + damagePerAgility * caster.agility
|
|
30
|
+
end
|
|
31
|
+
local damagePerIntelligence = self:resolveCurrentAbilityDependentValue(parameters and parameters.damagePerIntelligence or 0)
|
|
32
|
+
if damagePerIntelligence ~= 0 then
|
|
33
|
+
damage = damage + damagePerIntelligence * caster.intelligence
|
|
34
|
+
end
|
|
35
|
+
return damage
|
|
36
|
+
end
|
|
12
37
|
____exports.DamageSelfAbilityBehavior = __TS__Class()
|
|
13
38
|
local DamageSelfAbilityBehavior = ____exports.DamageSelfAbilityBehavior
|
|
14
39
|
DamageSelfAbilityBehavior.name = "DamageSelfAbilityBehavior"
|
|
15
|
-
__TS__ClassExtends(DamageSelfAbilityBehavior,
|
|
16
|
-
function DamageSelfAbilityBehavior.prototype.____constructor(self, ability, damage,
|
|
17
|
-
|
|
18
|
-
self.damage = damage
|
|
19
|
-
self.attackType = attackType
|
|
20
|
-
self.damageType = damageType
|
|
21
|
-
self.weaponType = weaponType
|
|
40
|
+
__TS__ClassExtends(DamageSelfAbilityBehavior, DamageAbilityBehavior)
|
|
41
|
+
function DamageSelfAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
|
|
42
|
+
DamageAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
|
|
22
43
|
end
|
|
23
44
|
function DamageSelfAbilityBehavior.prototype.onImpact(self, caster)
|
|
45
|
+
local parameters = self.parameters
|
|
24
46
|
caster:damageTarget(
|
|
25
47
|
caster,
|
|
26
|
-
self:
|
|
48
|
+
self:calculateDamage(caster),
|
|
27
49
|
nil,
|
|
28
50
|
nil,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
51
|
+
parameters and parameters.attackType,
|
|
52
|
+
parameters and parameters.damageType,
|
|
53
|
+
parameters and parameters.weaponType
|
|
32
54
|
)
|
|
33
55
|
end
|
|
34
56
|
____exports.DamageTargetAbilityBehavior = __TS__Class()
|
|
35
57
|
local DamageTargetAbilityBehavior = ____exports.DamageTargetAbilityBehavior
|
|
36
58
|
DamageTargetAbilityBehavior.name = "DamageTargetAbilityBehavior"
|
|
37
|
-
__TS__ClassExtends(DamageTargetAbilityBehavior,
|
|
38
|
-
function DamageTargetAbilityBehavior.prototype.____constructor(self, ability, damage,
|
|
39
|
-
|
|
40
|
-
self.damage = damage
|
|
41
|
-
self.attackType = attackType
|
|
42
|
-
self.damageType = damageType
|
|
43
|
-
self.weaponType = weaponType
|
|
59
|
+
__TS__ClassExtends(DamageTargetAbilityBehavior, DamageAbilityBehavior)
|
|
60
|
+
function DamageTargetAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
|
|
61
|
+
DamageAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
|
|
44
62
|
end
|
|
45
63
|
function DamageTargetAbilityBehavior.prototype.onWidgetTargetImpact(self, caster, target)
|
|
64
|
+
local parameters = self.parameters
|
|
46
65
|
caster:damageTarget(
|
|
47
66
|
target,
|
|
48
|
-
self:
|
|
67
|
+
self:calculateDamage(caster),
|
|
49
68
|
nil,
|
|
50
69
|
nil,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
70
|
+
parameters and parameters.attackType,
|
|
71
|
+
parameters and parameters.damageType,
|
|
72
|
+
parameters and parameters.weaponType
|
|
54
73
|
)
|
|
55
74
|
end
|
|
56
75
|
local DamageAreaAbilityBehavior = __TS__Class()
|
|
57
76
|
DamageAreaAbilityBehavior.name = "DamageAreaAbilityBehavior"
|
|
58
|
-
__TS__ClassExtends(DamageAreaAbilityBehavior,
|
|
59
|
-
function DamageAreaAbilityBehavior.prototype.____constructor(self, ability, damage,
|
|
60
|
-
|
|
61
|
-
self.damage = damage
|
|
62
|
-
self.maximumDamage = maximumDamage
|
|
63
|
-
self.attackType = attackType
|
|
64
|
-
self.damageType = damageType
|
|
65
|
-
self.weaponType = weaponType
|
|
77
|
+
__TS__ClassExtends(DamageAreaAbilityBehavior, DamageAbilityBehavior)
|
|
78
|
+
function DamageAreaAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
|
|
79
|
+
DamageAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
|
|
66
80
|
end
|
|
67
81
|
function DamageAreaAbilityBehavior.prototype.damageArea(self, caster, x, y)
|
|
82
|
+
local parameters = self.parameters
|
|
68
83
|
local targets = Unit.getAllowedTargetsInCollisionRange(
|
|
69
84
|
caster,
|
|
70
85
|
self:resolveCurrentAbilityDependentValue(ALLOWED_TARGETS_ABILITY_COMBAT_CLASSIFICATIONS_LEVEL_FIELD),
|
|
@@ -72,8 +87,8 @@ function DamageAreaAbilityBehavior.prototype.damageArea(self, caster, x, y)
|
|
|
72
87
|
y,
|
|
73
88
|
self:resolveCurrentAbilityDependentValue(AREA_OF_EFFECT_ABILITY_FLOAT_LEVEL_FIELD)
|
|
74
89
|
)
|
|
75
|
-
local damage = self:
|
|
76
|
-
local maximumDamage = self:resolveCurrentAbilityDependentValue(
|
|
90
|
+
local damage = self:calculateDamage(caster)
|
|
91
|
+
local maximumDamage = self:resolveCurrentAbilityDependentValue(parameters and parameters.maximumDamage or 0)
|
|
77
92
|
if maximumDamage ~= 0 and damage > maximumDamage then
|
|
78
93
|
damage = maximumDamage / #targets
|
|
79
94
|
end
|
|
@@ -83,9 +98,9 @@ function DamageAreaAbilityBehavior.prototype.damageArea(self, caster, x, y)
|
|
|
83
98
|
damage,
|
|
84
99
|
nil,
|
|
85
100
|
nil,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
101
|
+
parameters and parameters.attackType,
|
|
102
|
+
parameters and parameters.damageType,
|
|
103
|
+
parameters and parameters.weaponType
|
|
89
104
|
)
|
|
90
105
|
end
|
|
91
106
|
end
|
|
@@ -93,16 +108,8 @@ ____exports.DamageSelfAreaAbilityBehavior = __TS__Class()
|
|
|
93
108
|
local DamageSelfAreaAbilityBehavior = ____exports.DamageSelfAreaAbilityBehavior
|
|
94
109
|
DamageSelfAreaAbilityBehavior.name = "DamageSelfAreaAbilityBehavior"
|
|
95
110
|
__TS__ClassExtends(DamageSelfAreaAbilityBehavior, DamageAreaAbilityBehavior)
|
|
96
|
-
function DamageSelfAreaAbilityBehavior.prototype.____constructor(self, ability, damage,
|
|
97
|
-
DamageAreaAbilityBehavior.prototype.____constructor(
|
|
98
|
-
self,
|
|
99
|
-
ability,
|
|
100
|
-
damage,
|
|
101
|
-
maximumDamage,
|
|
102
|
-
attackType,
|
|
103
|
-
damageType,
|
|
104
|
-
weaponType
|
|
105
|
-
)
|
|
111
|
+
function DamageSelfAreaAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
|
|
112
|
+
DamageAreaAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
|
|
106
113
|
end
|
|
107
114
|
function DamageSelfAreaAbilityBehavior.prototype.onImpact(self, caster)
|
|
108
115
|
self:damageArea(caster, caster.x, caster.y)
|
|
@@ -111,16 +118,8 @@ ____exports.DamageTargetAreaAbilityBehavior = __TS__Class()
|
|
|
111
118
|
local DamageTargetAreaAbilityBehavior = ____exports.DamageTargetAreaAbilityBehavior
|
|
112
119
|
DamageTargetAreaAbilityBehavior.name = "DamageTargetAreaAbilityBehavior"
|
|
113
120
|
__TS__ClassExtends(DamageTargetAreaAbilityBehavior, DamageAreaAbilityBehavior)
|
|
114
|
-
function DamageTargetAreaAbilityBehavior.prototype.____constructor(self, ability, damage,
|
|
115
|
-
DamageAreaAbilityBehavior.prototype.____constructor(
|
|
116
|
-
self,
|
|
117
|
-
ability,
|
|
118
|
-
damage,
|
|
119
|
-
maximumDamage,
|
|
120
|
-
attackType,
|
|
121
|
-
damageType,
|
|
122
|
-
weaponType
|
|
123
|
-
)
|
|
121
|
+
function DamageTargetAreaAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
|
|
122
|
+
DamageAreaAbilityBehavior.prototype.____constructor(self, ability, damage, parameters)
|
|
124
123
|
end
|
|
125
124
|
function DamageTargetAreaAbilityBehavior.prototype.onNoTargetImpact(self, caster)
|
|
126
125
|
self:damageArea(caster, caster.x, caster.y)
|
|
@@ -4,13 +4,40 @@ import { Ability } from "../../internal/ability";
|
|
|
4
4
|
import { Unit } from "../../internal/unit";
|
|
5
5
|
import { AbilityDependentValue } from "../../object-field/ability";
|
|
6
6
|
import { AbilityBehavior } from "../ability";
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export type HealAbilityBehaviorParameters = {
|
|
8
|
+
healingPerStrength?: AbilityDependentValue<number>;
|
|
9
|
+
healingPerAgility?: AbilityDependentValue<number>;
|
|
10
|
+
healingPerIntelligence?: AbilityDependentValue<number>;
|
|
11
|
+
};
|
|
12
|
+
export type HealAreaAbilityBehaviorParameters = HealAbilityBehaviorParameters & {
|
|
13
|
+
maximumHealing?: AbilityDependentValue<number>;
|
|
14
|
+
};
|
|
15
|
+
declare abstract class HealAbilityBehavior<T extends HealAbilityBehaviorParameters = HealAbilityBehaviorParameters> extends AbilityBehavior {
|
|
16
|
+
protected readonly healing: AbilityDependentValue<number>;
|
|
17
|
+
protected readonly parameters?: T | undefined;
|
|
18
|
+
protected constructor(ability: Ability, healing: AbilityDependentValue<number>, parameters?: T | undefined);
|
|
19
|
+
protected calculateHealing(caster: Unit): number;
|
|
20
|
+
}
|
|
21
|
+
export declare class HealSelfAbilityBehavior extends HealAbilityBehavior {
|
|
22
|
+
constructor(ability: Ability, healing: AbilityDependentValue<number>, parameters?: HealAbilityBehaviorParameters);
|
|
23
|
+
onImpact(caster: Unit): void;
|
|
24
|
+
}
|
|
25
|
+
export declare class HealTargetAbilityBehavior extends HealAbilityBehavior {
|
|
26
|
+
constructor(ability: Ability, healing: AbilityDependentValue<number>, parameters?: HealAbilityBehaviorParameters);
|
|
27
|
+
onWidgetTargetImpact(caster: Unit, target: Widget): void;
|
|
28
|
+
}
|
|
29
|
+
declare abstract class HealAreaAbilityBehavior extends HealAbilityBehavior<HealAreaAbilityBehaviorParameters> {
|
|
30
|
+
protected constructor(ability: Ability, healing: AbilityDependentValue<number>, parameters?: HealAreaAbilityBehaviorParameters);
|
|
31
|
+
protected healArea(caster: Unit, x: number, y: number): void;
|
|
32
|
+
}
|
|
33
|
+
export declare class HealSelfAreaAbilityBehavior extends HealAreaAbilityBehavior {
|
|
34
|
+
constructor(ability: Ability, healing: AbilityDependentValue<number>, parameters?: HealAreaAbilityBehaviorParameters);
|
|
10
35
|
onImpact(caster: Unit): void;
|
|
11
36
|
}
|
|
12
|
-
export declare class
|
|
13
|
-
|
|
14
|
-
|
|
37
|
+
export declare class HealTargetAreaAbilityBehavior extends HealAreaAbilityBehavior {
|
|
38
|
+
constructor(ability: Ability, healing: AbilityDependentValue<number>, parameters?: HealAreaAbilityBehaviorParameters);
|
|
39
|
+
onNoTargetImpact(caster: Unit): void;
|
|
15
40
|
onWidgetTargetImpact(caster: Unit, target: Widget): void;
|
|
41
|
+
onPointTargetImpact(caster: Unit, x: number, y: number): void;
|
|
16
42
|
}
|
|
43
|
+
export {};
|
|
@@ -2,34 +2,113 @@ local ____lualib = require("lualib_bundle")
|
|
|
2
2
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
3
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
4
4
|
local ____exports = {}
|
|
5
|
+
local ____unit = require("engine.internal.unit")
|
|
6
|
+
local Unit = ____unit.Unit
|
|
5
7
|
local ____ability = require("engine.behaviour.ability")
|
|
6
8
|
local AbilityBehavior = ____ability.AbilityBehavior
|
|
9
|
+
local ____ability = require("engine.standard.fields.ability")
|
|
10
|
+
local ALLOWED_TARGETS_ABILITY_COMBAT_CLASSIFICATIONS_LEVEL_FIELD = ____ability.ALLOWED_TARGETS_ABILITY_COMBAT_CLASSIFICATIONS_LEVEL_FIELD
|
|
11
|
+
local AREA_OF_EFFECT_ABILITY_FLOAT_LEVEL_FIELD = ____ability.AREA_OF_EFFECT_ABILITY_FLOAT_LEVEL_FIELD
|
|
12
|
+
local HealAbilityBehavior = __TS__Class()
|
|
13
|
+
HealAbilityBehavior.name = "HealAbilityBehavior"
|
|
14
|
+
__TS__ClassExtends(HealAbilityBehavior, AbilityBehavior)
|
|
15
|
+
function HealAbilityBehavior.prototype.____constructor(self, ability, healing, parameters)
|
|
16
|
+
AbilityBehavior.prototype.____constructor(self, ability)
|
|
17
|
+
self.healing = healing
|
|
18
|
+
self.parameters = parameters
|
|
19
|
+
end
|
|
20
|
+
function HealAbilityBehavior.prototype.calculateHealing(self, caster)
|
|
21
|
+
local parameters = self.parameters
|
|
22
|
+
local healing = self:resolveCurrentAbilityDependentValue(self.healing)
|
|
23
|
+
local healingPerStrength = self:resolveCurrentAbilityDependentValue(parameters and parameters.healingPerStrength or 0)
|
|
24
|
+
if healingPerStrength ~= 0 then
|
|
25
|
+
healing = healing + healingPerStrength * caster.strength
|
|
26
|
+
end
|
|
27
|
+
local healingPerAgility = self:resolveCurrentAbilityDependentValue(parameters and parameters.healingPerAgility or 0)
|
|
28
|
+
if healingPerAgility ~= 0 then
|
|
29
|
+
healing = healing + healingPerAgility * caster.agility
|
|
30
|
+
end
|
|
31
|
+
local healingPerIntelligence = self:resolveCurrentAbilityDependentValue(parameters and parameters.healingPerIntelligence or 0)
|
|
32
|
+
if healingPerIntelligence ~= 0 then
|
|
33
|
+
healing = healing + healingPerIntelligence * caster.intelligence
|
|
34
|
+
end
|
|
35
|
+
return healing
|
|
36
|
+
end
|
|
7
37
|
____exports.HealSelfAbilityBehavior = __TS__Class()
|
|
8
38
|
local HealSelfAbilityBehavior = ____exports.HealSelfAbilityBehavior
|
|
9
39
|
HealSelfAbilityBehavior.name = "HealSelfAbilityBehavior"
|
|
10
|
-
__TS__ClassExtends(HealSelfAbilityBehavior,
|
|
11
|
-
function HealSelfAbilityBehavior.prototype.____constructor(self, ability, healing)
|
|
12
|
-
|
|
13
|
-
self.healing = healing
|
|
40
|
+
__TS__ClassExtends(HealSelfAbilityBehavior, HealAbilityBehavior)
|
|
41
|
+
function HealSelfAbilityBehavior.prototype.____constructor(self, ability, healing, parameters)
|
|
42
|
+
HealAbilityBehavior.prototype.____constructor(self, ability, healing, parameters)
|
|
14
43
|
end
|
|
15
44
|
function HealSelfAbilityBehavior.prototype.onImpact(self, caster)
|
|
16
45
|
caster:healTarget(
|
|
17
46
|
caster,
|
|
18
|
-
self:
|
|
47
|
+
self:calculateHealing(caster)
|
|
19
48
|
)
|
|
20
49
|
end
|
|
21
50
|
____exports.HealTargetAbilityBehavior = __TS__Class()
|
|
22
51
|
local HealTargetAbilityBehavior = ____exports.HealTargetAbilityBehavior
|
|
23
52
|
HealTargetAbilityBehavior.name = "HealTargetAbilityBehavior"
|
|
24
|
-
__TS__ClassExtends(HealTargetAbilityBehavior,
|
|
25
|
-
function HealTargetAbilityBehavior.prototype.____constructor(self, ability, healing)
|
|
26
|
-
|
|
27
|
-
self.healing = healing
|
|
53
|
+
__TS__ClassExtends(HealTargetAbilityBehavior, HealAbilityBehavior)
|
|
54
|
+
function HealTargetAbilityBehavior.prototype.____constructor(self, ability, healing, parameters)
|
|
55
|
+
HealAbilityBehavior.prototype.____constructor(self, ability, healing, parameters)
|
|
28
56
|
end
|
|
29
57
|
function HealTargetAbilityBehavior.prototype.onWidgetTargetImpact(self, caster, target)
|
|
30
58
|
caster:healTarget(
|
|
31
59
|
target,
|
|
32
|
-
self:
|
|
60
|
+
self:calculateHealing(caster)
|
|
61
|
+
)
|
|
62
|
+
end
|
|
63
|
+
local HealAreaAbilityBehavior = __TS__Class()
|
|
64
|
+
HealAreaAbilityBehavior.name = "HealAreaAbilityBehavior"
|
|
65
|
+
__TS__ClassExtends(HealAreaAbilityBehavior, HealAbilityBehavior)
|
|
66
|
+
function HealAreaAbilityBehavior.prototype.____constructor(self, ability, healing, parameters)
|
|
67
|
+
HealAbilityBehavior.prototype.____constructor(self, ability, healing, parameters)
|
|
68
|
+
end
|
|
69
|
+
function HealAreaAbilityBehavior.prototype.healArea(self, caster, x, y)
|
|
70
|
+
local targets = Unit.getAllowedTargetsInCollisionRange(
|
|
71
|
+
caster,
|
|
72
|
+
self:resolveCurrentAbilityDependentValue(ALLOWED_TARGETS_ABILITY_COMBAT_CLASSIFICATIONS_LEVEL_FIELD),
|
|
73
|
+
x,
|
|
74
|
+
y,
|
|
75
|
+
self:resolveCurrentAbilityDependentValue(AREA_OF_EFFECT_ABILITY_FLOAT_LEVEL_FIELD)
|
|
33
76
|
)
|
|
77
|
+
local healing = self:calculateHealing(caster)
|
|
78
|
+
local ____self_resolveCurrentAbilityDependentValue_8 = self.resolveCurrentAbilityDependentValue
|
|
79
|
+
local ____opt_6 = self.parameters
|
|
80
|
+
local maximumHealing = ____self_resolveCurrentAbilityDependentValue_8(self, ____opt_6 and ____opt_6.maximumHealing or 0)
|
|
81
|
+
if maximumHealing ~= 0 and healing > maximumHealing then
|
|
82
|
+
healing = maximumHealing / #targets
|
|
83
|
+
end
|
|
84
|
+
for ____, target in ipairs(targets) do
|
|
85
|
+
caster:healTarget(target, healing)
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
____exports.HealSelfAreaAbilityBehavior = __TS__Class()
|
|
89
|
+
local HealSelfAreaAbilityBehavior = ____exports.HealSelfAreaAbilityBehavior
|
|
90
|
+
HealSelfAreaAbilityBehavior.name = "HealSelfAreaAbilityBehavior"
|
|
91
|
+
__TS__ClassExtends(HealSelfAreaAbilityBehavior, HealAreaAbilityBehavior)
|
|
92
|
+
function HealSelfAreaAbilityBehavior.prototype.____constructor(self, ability, healing, parameters)
|
|
93
|
+
HealAreaAbilityBehavior.prototype.____constructor(self, ability, healing, parameters)
|
|
94
|
+
end
|
|
95
|
+
function HealSelfAreaAbilityBehavior.prototype.onImpact(self, caster)
|
|
96
|
+
self:healArea(caster, caster.x, caster.y)
|
|
97
|
+
end
|
|
98
|
+
____exports.HealTargetAreaAbilityBehavior = __TS__Class()
|
|
99
|
+
local HealTargetAreaAbilityBehavior = ____exports.HealTargetAreaAbilityBehavior
|
|
100
|
+
HealTargetAreaAbilityBehavior.name = "HealTargetAreaAbilityBehavior"
|
|
101
|
+
__TS__ClassExtends(HealTargetAreaAbilityBehavior, HealAreaAbilityBehavior)
|
|
102
|
+
function HealTargetAreaAbilityBehavior.prototype.____constructor(self, ability, healing, parameters)
|
|
103
|
+
HealAreaAbilityBehavior.prototype.____constructor(self, ability, healing, parameters)
|
|
104
|
+
end
|
|
105
|
+
function HealTargetAreaAbilityBehavior.prototype.onNoTargetImpact(self, caster)
|
|
106
|
+
self:healArea(caster, caster.x, caster.y)
|
|
107
|
+
end
|
|
108
|
+
function HealTargetAreaAbilityBehavior.prototype.onWidgetTargetImpact(self, caster, target)
|
|
109
|
+
self:healArea(caster, target.x, target.y)
|
|
110
|
+
end
|
|
111
|
+
function HealTargetAreaAbilityBehavior.prototype.onPointTargetImpact(self, caster, x, y)
|
|
112
|
+
self:healArea(caster, x, y)
|
|
34
113
|
end
|
|
35
114
|
return ____exports
|
package/engine/buff.d.ts
CHANGED
|
@@ -64,6 +64,10 @@ export type BuffParameters<T extends Buff<any> = Buff> = Buff extends T ? {
|
|
|
64
64
|
disablesAutoAttack?: BooleanParameterValueType;
|
|
65
65
|
destroysOnDamage?: BooleanParameterValueType;
|
|
66
66
|
maximumAutoAttackCount?: IntegerParameterValueType;
|
|
67
|
+
damageOnExpiration?: NumberParameterValueType;
|
|
68
|
+
healingOnExpiration?: NumberParameterValueType;
|
|
69
|
+
killsOnExpiration?: BooleanParameterValueType;
|
|
70
|
+
explodesOnExpiration?: BooleanParameterValueType;
|
|
67
71
|
uniqueGroup?: BuffUniqueGroup;
|
|
68
72
|
} : BuffParameters & (T extends Buff<infer AdditionalParameters> ? AdditionalParameters : object);
|
|
69
73
|
declare const enum BuffPropertyKey {
|
|
@@ -86,19 +90,23 @@ declare const enum BuffPropertyKey {
|
|
|
86
90
|
HEALING_INTERVAL = 116,
|
|
87
91
|
REMAINING_HEALING_OVER_DURATION = 117,
|
|
88
92
|
HEALING_INTERVAL_TIMER = 118,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
93
|
+
DAMAGE_ON_EXPIRATION = 119,
|
|
94
|
+
HEALING_ON_EXPIRATION = 120,
|
|
95
|
+
DAMAGE_UPON_DEATH_ALLOWED_TARGET_CLASSIFICATIONS = 121,
|
|
96
|
+
DAMAGE_UPON_DEATH = 122,
|
|
97
|
+
DAMAGE_UPON_DEATH_RANGE = 123,
|
|
98
|
+
MEDIUM_DAMAGE_UPON_DEATH = 124,
|
|
99
|
+
MEDIUM_DAMAGE_UPON_DEATH_RANGE = 125,
|
|
100
|
+
SMALL_DAMAGE_UPON_DEATH = 126,
|
|
101
|
+
SMALL_DAMAGE_UPON_DEATH_RANGE = 127,
|
|
102
|
+
AUTO_ATTACK_COUNT = 128,
|
|
103
|
+
MAXIMUM_AUTO_ATTACK_COUNT = 129,
|
|
104
|
+
STUNS = 130,
|
|
105
|
+
IGNORES_STUN_IMMUNITY = 131,
|
|
106
|
+
DISABLES_AUTO_ATTACK = 132,
|
|
107
|
+
PROVIDES_INVULNERABILITY = 133,
|
|
108
|
+
KILLS_ON_EXPIRATION = 134,
|
|
109
|
+
EXPLODES_ON_EXPIRATION = 135
|
|
102
110
|
}
|
|
103
111
|
export declare const enum BuffTypeIdSelectionPolicy {
|
|
104
112
|
LEAST_DURATION = 0
|
|
@@ -138,6 +146,8 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
|
|
|
138
146
|
private [BuffPropertyKey.HEALING_INTERVAL]?;
|
|
139
147
|
private [BuffPropertyKey.REMAINING_HEALING_OVER_DURATION]?;
|
|
140
148
|
private [BuffPropertyKey.HEALING_INTERVAL_TIMER]?;
|
|
149
|
+
private [BuffPropertyKey.DAMAGE_ON_EXPIRATION]?;
|
|
150
|
+
private [BuffPropertyKey.HEALING_ON_EXPIRATION]?;
|
|
141
151
|
private [BuffPropertyKey.DAMAGE_UPON_DEATH_ALLOWED_TARGET_CLASSIFICATIONS]?;
|
|
142
152
|
private [BuffPropertyKey.DAMAGE_UPON_DEATH]?;
|
|
143
153
|
private [BuffPropertyKey.DAMAGE_UPON_DEATH_RANGE]?;
|
|
@@ -151,6 +161,8 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
|
|
|
151
161
|
private [BuffPropertyKey.IGNORES_STUN_IMMUNITY]?;
|
|
152
162
|
private [BuffPropertyKey.DISABLES_AUTO_ATTACK]?;
|
|
153
163
|
private [BuffPropertyKey.PROVIDES_INVULNERABILITY]?;
|
|
164
|
+
private [BuffPropertyKey.KILLS_ON_EXPIRATION]?;
|
|
165
|
+
private [BuffPropertyKey.EXPLODES_ON_EXPIRATION]?;
|
|
154
166
|
protected static readonly defaultParameters: BuffParameters;
|
|
155
167
|
get source(): Unit;
|
|
156
168
|
readonly typeId: ApplicableBuffTypeId;
|
|
@@ -187,6 +199,10 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
|
|
|
187
199
|
set healingPerInterval(healingPerInterval: number);
|
|
188
200
|
get healingInterval(): number;
|
|
189
201
|
set healingInterval(healingInterval: number);
|
|
202
|
+
get damageOnExpiration(): number;
|
|
203
|
+
set damageOnExpiration(damageOnExpiration: number);
|
|
204
|
+
get healingOnExpiration(): number;
|
|
205
|
+
set healingOnExpiration(healingOnExpiration: number);
|
|
190
206
|
get receivedDamageFactor(): number;
|
|
191
207
|
set receivedDamageFactor(receivedDamageFactor: number);
|
|
192
208
|
get armorIncrease(): number;
|
|
@@ -199,6 +215,10 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
|
|
|
199
215
|
set disablesAutoAttack(disablesAutoAttack: boolean);
|
|
200
216
|
get providesInvulnerability(): boolean;
|
|
201
217
|
set providesInvulnerability(providesInvulnerability: boolean);
|
|
218
|
+
get killsOnExpiration(): boolean;
|
|
219
|
+
set killsOnExpiration(killsOnExpiration: boolean);
|
|
220
|
+
get explodesOnExpiration(): boolean;
|
|
221
|
+
set explodesOnExpiration(killsOnExpiration: boolean);
|
|
202
222
|
get maximumAutoAttackCount(): number;
|
|
203
223
|
set maximumAutoAttackCount(maximumAutoAttackCount: number);
|
|
204
224
|
get durationIncreaseOnAutoAttack(): number;
|
|
@@ -215,6 +235,7 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
|
|
|
215
235
|
protected onDestroy(): Destructor;
|
|
216
236
|
static apply<T extends Buff<any>, Args extends any[]>(this: BuffConstructor<T, Args>, ...args: Args): T | undefined;
|
|
217
237
|
static getByTypeId<T extends Buff<any>, Args extends any[]>(this: BuffConstructor<T, Args>, unit: Unit, typeId: ApplicableBuffTypeId): T | undefined;
|
|
238
|
+
onExpiration(): void;
|
|
218
239
|
onDeath(source: Unit | undefined): void;
|
|
219
240
|
onDamageDealt(target: Unit, event: DamageEvent): void;
|
|
220
241
|
}
|
package/engine/buff.lua
CHANGED
|
@@ -107,7 +107,11 @@ local buffParametersKeys = {
|
|
|
107
107
|
disablesAutoAttack = true,
|
|
108
108
|
destroysOnDamage = true,
|
|
109
109
|
maximumAutoAttackCount = true,
|
|
110
|
-
uniqueGroup = true
|
|
110
|
+
uniqueGroup = true,
|
|
111
|
+
damageOnExpiration = true,
|
|
112
|
+
healingOnExpiration = true,
|
|
113
|
+
killsOnExpiration = true,
|
|
114
|
+
explodesOnExpiration = true
|
|
111
115
|
}
|
|
112
116
|
local function resolveNumberValue(ability, level, value)
|
|
113
117
|
if value == nil or type(value) == "number" then
|
|
@@ -145,7 +149,14 @@ local function resolveAndSetNumberValue(buff, property, ability, level, value, d
|
|
|
145
149
|
buff[property] = resolvedValue
|
|
146
150
|
end
|
|
147
151
|
end
|
|
148
|
-
local buffBooleanParameters = {
|
|
152
|
+
local buffBooleanParameters = {
|
|
153
|
+
"stuns",
|
|
154
|
+
"ignoresStunImmunity",
|
|
155
|
+
"disablesAutoAttack",
|
|
156
|
+
"providesInvulnerability",
|
|
157
|
+
"killsOnExpiration",
|
|
158
|
+
"explodesOnExpiration"
|
|
159
|
+
}
|
|
149
160
|
local buffNumberParameters = {
|
|
150
161
|
"durationIncreaseOnAutoAttack",
|
|
151
162
|
"attackSpeedIncreaseFactor",
|
|
@@ -158,7 +169,9 @@ local buffNumberParameters = {
|
|
|
158
169
|
"damageOverDuration",
|
|
159
170
|
"healingInterval",
|
|
160
171
|
"healingPerInterval",
|
|
161
|
-
"healingOverDuration"
|
|
172
|
+
"healingOverDuration",
|
|
173
|
+
"damageOnExpiration",
|
|
174
|
+
"healingOnExpiration"
|
|
162
175
|
}
|
|
163
176
|
local unsuccessfulApplicationMarker = {}
|
|
164
177
|
local function selectBuffTypeIdWithLeastDuration(buffTypeIds, unit)
|
|
@@ -207,6 +220,7 @@ local function expireBuff(buff)
|
|
|
207
220
|
end
|
|
208
221
|
end
|
|
209
222
|
Timer:run(destroyBuff, buff)
|
|
223
|
+
buff:onExpiration()
|
|
210
224
|
end
|
|
211
225
|
local function buffDamageIntervalInitialTimerCallback(buff)
|
|
212
226
|
buffDamageIntervalTimerCallback(buff)
|
|
@@ -530,11 +544,11 @@ function Buff.prototype.onDestroy(self)
|
|
|
530
544
|
behavior:destroy()
|
|
531
545
|
end
|
|
532
546
|
end
|
|
533
|
-
if self[
|
|
547
|
+
if self[132] then
|
|
534
548
|
unit:decrementDisableAutoAttackCounter()
|
|
535
549
|
end
|
|
536
|
-
if self[
|
|
537
|
-
if self[
|
|
550
|
+
if self[130] then
|
|
551
|
+
if self[131] then
|
|
538
552
|
unit:decrementStunCounter()
|
|
539
553
|
end
|
|
540
554
|
unit:decrementStunCounter()
|
|
@@ -583,20 +597,34 @@ function Buff.getByTypeId(self, unit, typeId)
|
|
|
583
597
|
end
|
|
584
598
|
return nil
|
|
585
599
|
end
|
|
586
|
-
function Buff.prototype.
|
|
600
|
+
function Buff.prototype.onExpiration(self)
|
|
587
601
|
local unit = self.unit
|
|
588
602
|
if self[119] ~= nil then
|
|
603
|
+
(self[101] or unit):damageTarget(unit, self[119] or 0)
|
|
604
|
+
end
|
|
605
|
+
if self[120] ~= nil then
|
|
606
|
+
(self[101] or unit):healTarget(unit, self[119] or 0)
|
|
607
|
+
end
|
|
608
|
+
if self[135] then
|
|
609
|
+
unit:explode()
|
|
610
|
+
elseif self[134] then
|
|
611
|
+
unit:kill()
|
|
612
|
+
end
|
|
613
|
+
end
|
|
614
|
+
function Buff.prototype.onDeath(self, source)
|
|
615
|
+
local unit = self.unit
|
|
616
|
+
if self[121] ~= nil then
|
|
589
617
|
damageArea(
|
|
590
618
|
self[101] or unit,
|
|
591
|
-
self[
|
|
619
|
+
self[121],
|
|
592
620
|
unit.x,
|
|
593
621
|
unit.y,
|
|
594
|
-
self[121] or 0,
|
|
595
|
-
self[120] or 0,
|
|
596
622
|
self[123] or 0,
|
|
597
623
|
self[122] or 0,
|
|
598
624
|
self[125] or 0,
|
|
599
|
-
self[124] or 0
|
|
625
|
+
self[124] or 0,
|
|
626
|
+
self[127] or 0,
|
|
627
|
+
self[126] or 0
|
|
600
628
|
)
|
|
601
629
|
end
|
|
602
630
|
end
|
|
@@ -618,9 +646,9 @@ function Buff.prototype.onDamageDealt(self, target, event)
|
|
|
618
646
|
end
|
|
619
647
|
self.remainingDuration = remainingDuration
|
|
620
648
|
end
|
|
621
|
-
local autoAttackCount = (self[
|
|
622
|
-
self[
|
|
623
|
-
if autoAttackCount == self[
|
|
649
|
+
local autoAttackCount = (self[128] or 0) + 1
|
|
650
|
+
self[128] = autoAttackCount
|
|
651
|
+
if autoAttackCount == self[129] then
|
|
624
652
|
self:destroy()
|
|
625
653
|
end
|
|
626
654
|
end
|
|
@@ -802,6 +830,32 @@ __TS__SetDescriptor(
|
|
|
802
830
|
},
|
|
803
831
|
true
|
|
804
832
|
)
|
|
833
|
+
__TS__SetDescriptor(
|
|
834
|
+
Buff.prototype,
|
|
835
|
+
"damageOnExpiration",
|
|
836
|
+
{
|
|
837
|
+
get = function(self)
|
|
838
|
+
return self[119] or 0
|
|
839
|
+
end,
|
|
840
|
+
set = function(self, damageOnExpiration)
|
|
841
|
+
self[119] = damageOnExpiration ~= 0 and damageOnExpiration or nil
|
|
842
|
+
end
|
|
843
|
+
},
|
|
844
|
+
true
|
|
845
|
+
)
|
|
846
|
+
__TS__SetDescriptor(
|
|
847
|
+
Buff.prototype,
|
|
848
|
+
"healingOnExpiration",
|
|
849
|
+
{
|
|
850
|
+
get = function(self)
|
|
851
|
+
return self[120] or 0
|
|
852
|
+
end,
|
|
853
|
+
set = function(self, healingOnExpiration)
|
|
854
|
+
self[120] = healingOnExpiration ~= 0 and healingOnExpiration or nil
|
|
855
|
+
end
|
|
856
|
+
},
|
|
857
|
+
true
|
|
858
|
+
)
|
|
805
859
|
__TS__SetDescriptor(
|
|
806
860
|
Buff.prototype,
|
|
807
861
|
"receivedDamageFactor",
|
|
@@ -833,25 +887,25 @@ __TS__SetDescriptor(
|
|
|
833
887
|
"stuns",
|
|
834
888
|
{
|
|
835
889
|
get = function(self)
|
|
836
|
-
local
|
|
837
|
-
if
|
|
838
|
-
|
|
890
|
+
local ____self__130_52 = self[130]
|
|
891
|
+
if ____self__130_52 == nil then
|
|
892
|
+
____self__130_52 = false
|
|
839
893
|
end
|
|
840
|
-
return
|
|
894
|
+
return ____self__130_52
|
|
841
895
|
end,
|
|
842
896
|
set = function(self, stuns)
|
|
843
|
-
if not stuns and self[
|
|
844
|
-
if self[
|
|
897
|
+
if not stuns and self[130] then
|
|
898
|
+
if self[131] then
|
|
845
899
|
self.object:decrementStunCounter()
|
|
846
900
|
end
|
|
847
901
|
self.object:decrementStunCounter()
|
|
848
|
-
self[
|
|
849
|
-
elseif stuns and not self[
|
|
850
|
-
if self[
|
|
902
|
+
self[130] = nil
|
|
903
|
+
elseif stuns and not self[130] then
|
|
904
|
+
if self[131] then
|
|
851
905
|
self.object:incrementStunCounter()
|
|
852
906
|
end
|
|
853
907
|
self.object:incrementStunCounter()
|
|
854
|
-
self[
|
|
908
|
+
self[130] = true
|
|
855
909
|
end
|
|
856
910
|
end
|
|
857
911
|
},
|
|
@@ -862,23 +916,23 @@ __TS__SetDescriptor(
|
|
|
862
916
|
"ignoresStunImmunity",
|
|
863
917
|
{
|
|
864
918
|
get = function(self)
|
|
865
|
-
local
|
|
866
|
-
if
|
|
867
|
-
|
|
919
|
+
local ____self__131_53 = self[131]
|
|
920
|
+
if ____self__131_53 == nil then
|
|
921
|
+
____self__131_53 = false
|
|
868
922
|
end
|
|
869
|
-
return
|
|
923
|
+
return ____self__131_53
|
|
870
924
|
end,
|
|
871
925
|
set = function(self, ignoresStunImmunity)
|
|
872
|
-
if not ignoresStunImmunity and self[
|
|
873
|
-
if self[
|
|
926
|
+
if not ignoresStunImmunity and self[131] then
|
|
927
|
+
if self[130] then
|
|
874
928
|
self.object:decrementStunCounter()
|
|
875
929
|
end
|
|
876
|
-
self[
|
|
877
|
-
elseif ignoresStunImmunity and not self[
|
|
878
|
-
if self[
|
|
930
|
+
self[131] = nil
|
|
931
|
+
elseif ignoresStunImmunity and not self[131] then
|
|
932
|
+
if self[130] then
|
|
879
933
|
self.object:incrementStunCounter()
|
|
880
934
|
end
|
|
881
|
-
self[
|
|
935
|
+
self[131] = true
|
|
882
936
|
end
|
|
883
937
|
end
|
|
884
938
|
},
|
|
@@ -889,19 +943,19 @@ __TS__SetDescriptor(
|
|
|
889
943
|
"disablesAutoAttack",
|
|
890
944
|
{
|
|
891
945
|
get = function(self)
|
|
892
|
-
local
|
|
893
|
-
if
|
|
894
|
-
|
|
946
|
+
local ____self__132_54 = self[132]
|
|
947
|
+
if ____self__132_54 == nil then
|
|
948
|
+
____self__132_54 = false
|
|
895
949
|
end
|
|
896
|
-
return
|
|
950
|
+
return ____self__132_54
|
|
897
951
|
end,
|
|
898
952
|
set = function(self, disablesAutoAttack)
|
|
899
|
-
if not disablesAutoAttack and self[
|
|
953
|
+
if not disablesAutoAttack and self[132] then
|
|
900
954
|
self.object:decrementDisableAutoAttackCounter()
|
|
901
|
-
self[
|
|
902
|
-
elseif disablesAutoAttack and not self[
|
|
955
|
+
self[132] = nil
|
|
956
|
+
elseif disablesAutoAttack and not self[132] then
|
|
903
957
|
self.object:incrementDisableAutoAttackCounter()
|
|
904
|
-
self[
|
|
958
|
+
self[132] = true
|
|
905
959
|
end
|
|
906
960
|
end
|
|
907
961
|
},
|
|
@@ -912,19 +966,61 @@ __TS__SetDescriptor(
|
|
|
912
966
|
"providesInvulnerability",
|
|
913
967
|
{
|
|
914
968
|
get = function(self)
|
|
915
|
-
local
|
|
916
|
-
if
|
|
917
|
-
|
|
969
|
+
local ____self__133_55 = self[133]
|
|
970
|
+
if ____self__133_55 == nil then
|
|
971
|
+
____self__133_55 = false
|
|
918
972
|
end
|
|
919
|
-
return
|
|
973
|
+
return ____self__133_55
|
|
920
974
|
end,
|
|
921
975
|
set = function(self, providesInvulnerability)
|
|
922
|
-
if not providesInvulnerability and self[
|
|
976
|
+
if not providesInvulnerability and self[133] then
|
|
923
977
|
self.object:decrementInvulnerabilityCounter()
|
|
924
|
-
self[
|
|
925
|
-
elseif providesInvulnerability and not self[
|
|
978
|
+
self[133] = nil
|
|
979
|
+
elseif providesInvulnerability and not self[133] then
|
|
926
980
|
self.object:incrementInvulnerabilityCounter()
|
|
927
|
-
self[
|
|
981
|
+
self[133] = true
|
|
982
|
+
end
|
|
983
|
+
end
|
|
984
|
+
},
|
|
985
|
+
true
|
|
986
|
+
)
|
|
987
|
+
__TS__SetDescriptor(
|
|
988
|
+
Buff.prototype,
|
|
989
|
+
"killsOnExpiration",
|
|
990
|
+
{
|
|
991
|
+
get = function(self)
|
|
992
|
+
local ____self__134_56 = self[134]
|
|
993
|
+
if ____self__134_56 == nil then
|
|
994
|
+
____self__134_56 = false
|
|
995
|
+
end
|
|
996
|
+
return ____self__134_56
|
|
997
|
+
end,
|
|
998
|
+
set = function(self, killsOnExpiration)
|
|
999
|
+
if not killsOnExpiration and self[134] then
|
|
1000
|
+
self[134] = nil
|
|
1001
|
+
elseif killsOnExpiration and not self[134] then
|
|
1002
|
+
self[134] = true
|
|
1003
|
+
end
|
|
1004
|
+
end
|
|
1005
|
+
},
|
|
1006
|
+
true
|
|
1007
|
+
)
|
|
1008
|
+
__TS__SetDescriptor(
|
|
1009
|
+
Buff.prototype,
|
|
1010
|
+
"explodesOnExpiration",
|
|
1011
|
+
{
|
|
1012
|
+
get = function(self)
|
|
1013
|
+
local ____self__135_57 = self[135]
|
|
1014
|
+
if ____self__135_57 == nil then
|
|
1015
|
+
____self__135_57 = false
|
|
1016
|
+
end
|
|
1017
|
+
return ____self__135_57
|
|
1018
|
+
end,
|
|
1019
|
+
set = function(self, killsOnExpiration)
|
|
1020
|
+
if not killsOnExpiration and self[135] then
|
|
1021
|
+
self[135] = nil
|
|
1022
|
+
elseif killsOnExpiration and not self[135] then
|
|
1023
|
+
self[135] = true
|
|
928
1024
|
end
|
|
929
1025
|
end
|
|
930
1026
|
},
|
|
@@ -935,13 +1031,13 @@ __TS__SetDescriptor(
|
|
|
935
1031
|
"maximumAutoAttackCount",
|
|
936
1032
|
{
|
|
937
1033
|
get = function(self)
|
|
938
|
-
return self[
|
|
1034
|
+
return self[129] or 0
|
|
939
1035
|
end,
|
|
940
1036
|
set = function(self, maximumAutoAttackCount)
|
|
941
1037
|
if maximumAutoAttackCount == 0 then
|
|
942
|
-
self[
|
|
1038
|
+
self[129] = nil
|
|
943
1039
|
else
|
|
944
|
-
self[
|
|
1040
|
+
self[129] = maximumAutoAttackCount
|
|
945
1041
|
end
|
|
946
1042
|
end
|
|
947
1043
|
},
|
|
@@ -999,13 +1095,13 @@ __TS__SetDescriptor(
|
|
|
999
1095
|
"remainingDuration",
|
|
1000
1096
|
{
|
|
1001
1097
|
get = function(self)
|
|
1002
|
-
local
|
|
1003
|
-
return
|
|
1098
|
+
local ____opt_58 = self._timer
|
|
1099
|
+
return ____opt_58 and ____opt_58.remaining or 0
|
|
1004
1100
|
end,
|
|
1005
1101
|
set = function(self, remainingDuration)
|
|
1006
|
-
local
|
|
1007
|
-
local
|
|
1008
|
-
local remainingDurationDelta =
|
|
1102
|
+
local ____remainingDuration_62 = remainingDuration
|
|
1103
|
+
local ____opt_60 = self._timer
|
|
1104
|
+
local remainingDurationDelta = ____remainingDuration_62 - (____opt_60 and ____opt_60.remaining or 0)
|
|
1009
1105
|
if remainingDurationDelta ~= 0 then
|
|
1010
1106
|
self[102] = self[102] + remainingDurationDelta
|
|
1011
1107
|
if remainingDuration <= 0 then
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "warscript",
|
|
4
|
-
"version": "0.0.1-dev.
|
|
4
|
+
"version": "0.0.1-dev.0e6c999",
|
|
5
5
|
"description": "A typescript library for Warcraft III using Warpack.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"warcraft",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@warscript/language-extensions": "^0.0.1",
|
|
25
25
|
"@warscript/tstl-plugin": "^0.0.4",
|
|
26
26
|
"lua-types": "^2.13.1",
|
|
27
|
-
"warpack": "0.0.1-dev.
|
|
27
|
+
"warpack": "0.0.1-dev.25a6bf5"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@typescript-eslint/eslint-plugin": "^8.13.0",
|
package/property.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import { Player } from "./core/types/player";
|
|
3
|
+
import { Event } from "./event";
|
|
4
|
+
export declare class PersistentPropertiesConfig {
|
|
5
|
+
static defaultFileName: string;
|
|
6
|
+
}
|
|
7
|
+
declare const enum PropertyPropertyKey {
|
|
8
|
+
DEFAULT_VALUE = 0,
|
|
9
|
+
VALUE = 1,
|
|
10
|
+
IS_CHANGED = 2
|
|
11
|
+
}
|
|
12
|
+
export declare class Property<T> {
|
|
13
|
+
readonly valueChangeEvent: Event<[newValue: T, oldValue: T]>;
|
|
14
|
+
private [PropertyPropertyKey.DEFAULT_VALUE];
|
|
15
|
+
private [PropertyPropertyKey.VALUE];
|
|
16
|
+
private [PropertyPropertyKey.IS_CHANGED]?;
|
|
17
|
+
constructor(defaultValue: T);
|
|
18
|
+
get defaultValue(): T;
|
|
19
|
+
set defaultValue(defaultValue: T);
|
|
20
|
+
get value(): T;
|
|
21
|
+
set value(value: T);
|
|
22
|
+
get isChanged(): boolean;
|
|
23
|
+
reset(): boolean;
|
|
24
|
+
set(value: T): boolean;
|
|
25
|
+
get(): T;
|
|
26
|
+
}
|
|
27
|
+
declare const enum PlayerPropertyPropertyKey {
|
|
28
|
+
DEFAULT_VALUE = 0,
|
|
29
|
+
VALUE_BY_PLAYER = 1,
|
|
30
|
+
IS_CHANGED_BY_PLAYER = 2
|
|
31
|
+
}
|
|
32
|
+
export declare class PlayerProperty<T> {
|
|
33
|
+
readonly valueChangeEvent: Event<[player: Player, newValue: T, oldValue: T]>;
|
|
34
|
+
private readonly [PlayerPropertyPropertyKey.DEFAULT_VALUE];
|
|
35
|
+
private readonly [PlayerPropertyPropertyKey.VALUE_BY_PLAYER];
|
|
36
|
+
private readonly [PlayerPropertyPropertyKey.IS_CHANGED_BY_PLAYER];
|
|
37
|
+
constructor(defaultValue: T);
|
|
38
|
+
isChanged(player: Player): boolean;
|
|
39
|
+
reset(player: Player): boolean;
|
|
40
|
+
set(player: Player, value: T): boolean;
|
|
41
|
+
get(player: Player): T;
|
|
42
|
+
}
|
|
43
|
+
export declare class PersistentProperty<T extends undefined | boolean | number | string> extends Property<T> {
|
|
44
|
+
readonly id: number;
|
|
45
|
+
constructor(id: number, defaultValue: T, valueChangeEventListener?: (newValue: T, oldValue: T) => void);
|
|
46
|
+
reset(): boolean;
|
|
47
|
+
set(value: T): boolean;
|
|
48
|
+
}
|
|
49
|
+
export declare class PersistentPlayerProperty<T extends string | number | boolean> extends PlayerProperty<T> {
|
|
50
|
+
readonly id: number;
|
|
51
|
+
constructor(id: number, initialValue: T, valueChangeEventListener?: (player: Player, newValue: T, oldValue: T) => void);
|
|
52
|
+
reset(player: Player): boolean;
|
|
53
|
+
set(player: Player, value: T): boolean;
|
|
54
|
+
}
|
|
55
|
+
export {};
|
package/property.lua
ADDED
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__Class = ____lualib.__TS__Class
|
|
3
|
+
local __TS__New = ____lualib.__TS__New
|
|
4
|
+
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
5
|
+
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
6
|
+
local ____exports = {}
|
|
7
|
+
local savePropertyValues
|
|
8
|
+
local ____binaryreader = require("binaryreader")
|
|
9
|
+
local BinaryReader = ____binaryreader.BinaryReader
|
|
10
|
+
local ____binarywriter = require("binarywriter")
|
|
11
|
+
local BinaryWriter = ____binarywriter.BinaryWriter
|
|
12
|
+
local ____player = require("core.types.player")
|
|
13
|
+
local Player = ____player.Player
|
|
14
|
+
local ____timer = require("core.types.timer")
|
|
15
|
+
local Timer = ____timer.Timer
|
|
16
|
+
local ____event = require("event")
|
|
17
|
+
local Event = ____event.Event
|
|
18
|
+
local file = require("file")
|
|
19
|
+
local ____network = require("network")
|
|
20
|
+
local synchronize = ____network.synchronize
|
|
21
|
+
local base64 = require("utility.base64")
|
|
22
|
+
local lzw = require("utility.lzw")
|
|
23
|
+
local ____preconditions = require("utility.preconditions")
|
|
24
|
+
local ____require = ____preconditions.require
|
|
25
|
+
local invoke = Event.invoke
|
|
26
|
+
____exports.PersistentPropertiesConfig = __TS__Class()
|
|
27
|
+
local PersistentPropertiesConfig = ____exports.PersistentPropertiesConfig
|
|
28
|
+
PersistentPropertiesConfig.name = "PersistentPropertiesConfig"
|
|
29
|
+
function PersistentPropertiesConfig.prototype.____constructor(self)
|
|
30
|
+
end
|
|
31
|
+
PersistentPropertiesConfig.defaultFileName = ""
|
|
32
|
+
____exports.Property = __TS__Class()
|
|
33
|
+
local Property = ____exports.Property
|
|
34
|
+
Property.name = "Property"
|
|
35
|
+
function Property.prototype.____constructor(self, defaultValue)
|
|
36
|
+
self.valueChangeEvent = __TS__New(Event)
|
|
37
|
+
self[0] = defaultValue
|
|
38
|
+
self[1] = defaultValue
|
|
39
|
+
end
|
|
40
|
+
function Property.prototype.reset(self)
|
|
41
|
+
if self[2] then
|
|
42
|
+
self[2] = nil
|
|
43
|
+
local defaultValue = self[0]
|
|
44
|
+
local oldValue = self[1]
|
|
45
|
+
if defaultValue ~= oldValue then
|
|
46
|
+
self[1] = defaultValue
|
|
47
|
+
invoke(self.valueChangeEvent, defaultValue, oldValue)
|
|
48
|
+
end
|
|
49
|
+
return true
|
|
50
|
+
end
|
|
51
|
+
return false
|
|
52
|
+
end
|
|
53
|
+
function Property.prototype.set(self, value)
|
|
54
|
+
self[2] = true
|
|
55
|
+
local oldValue = self[1]
|
|
56
|
+
self[1] = value
|
|
57
|
+
if value ~= oldValue then
|
|
58
|
+
invoke(self.valueChangeEvent, value, oldValue)
|
|
59
|
+
return true
|
|
60
|
+
end
|
|
61
|
+
return false
|
|
62
|
+
end
|
|
63
|
+
function Property.prototype.get(self)
|
|
64
|
+
return self[1]
|
|
65
|
+
end
|
|
66
|
+
__TS__SetDescriptor(
|
|
67
|
+
Property.prototype,
|
|
68
|
+
"defaultValue",
|
|
69
|
+
{
|
|
70
|
+
get = function(self)
|
|
71
|
+
return self[0]
|
|
72
|
+
end,
|
|
73
|
+
set = function(self, defaultValue)
|
|
74
|
+
local oldDefaultValue = self[0]
|
|
75
|
+
if defaultValue ~= oldDefaultValue then
|
|
76
|
+
self[0] = defaultValue
|
|
77
|
+
if not self[2] then
|
|
78
|
+
self[1] = defaultValue
|
|
79
|
+
invoke(self.valueChangeEvent, defaultValue, oldDefaultValue)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
},
|
|
84
|
+
true
|
|
85
|
+
)
|
|
86
|
+
__TS__SetDescriptor(
|
|
87
|
+
Property.prototype,
|
|
88
|
+
"value",
|
|
89
|
+
{
|
|
90
|
+
get = function(self)
|
|
91
|
+
return self:get()
|
|
92
|
+
end,
|
|
93
|
+
set = function(self, value)
|
|
94
|
+
self:set(value)
|
|
95
|
+
end
|
|
96
|
+
},
|
|
97
|
+
true
|
|
98
|
+
)
|
|
99
|
+
__TS__SetDescriptor(
|
|
100
|
+
Property.prototype,
|
|
101
|
+
"isChanged",
|
|
102
|
+
{get = function(self)
|
|
103
|
+
return self[2] == true
|
|
104
|
+
end},
|
|
105
|
+
true
|
|
106
|
+
)
|
|
107
|
+
____exports.PlayerProperty = __TS__Class()
|
|
108
|
+
local PlayerProperty = ____exports.PlayerProperty
|
|
109
|
+
PlayerProperty.name = "PlayerProperty"
|
|
110
|
+
function PlayerProperty.prototype.____constructor(self, defaultValue)
|
|
111
|
+
self.valueChangeEvent = __TS__New(Event)
|
|
112
|
+
self[0] = defaultValue
|
|
113
|
+
self[1] = {}
|
|
114
|
+
self[2] = {}
|
|
115
|
+
end
|
|
116
|
+
function PlayerProperty.prototype.isChanged(self, player)
|
|
117
|
+
return self[2][player] ~= nil
|
|
118
|
+
end
|
|
119
|
+
function PlayerProperty.prototype.reset(self, player)
|
|
120
|
+
if self[2][player] ~= nil then
|
|
121
|
+
self[2][player] = nil
|
|
122
|
+
local initialValue = self[0]
|
|
123
|
+
local oldValue = self[1][player]
|
|
124
|
+
self[1][player] = nil
|
|
125
|
+
if initialValue ~= oldValue then
|
|
126
|
+
invoke(self.valueChangeEvent, player, initialValue, oldValue)
|
|
127
|
+
end
|
|
128
|
+
return true
|
|
129
|
+
end
|
|
130
|
+
return false
|
|
131
|
+
end
|
|
132
|
+
function PlayerProperty.prototype.set(self, player, value)
|
|
133
|
+
self[2][player] = true
|
|
134
|
+
local oldValue = self[1][player]
|
|
135
|
+
self[1][player] = value
|
|
136
|
+
if value ~= oldValue then
|
|
137
|
+
invoke(self.valueChangeEvent, player, value, oldValue)
|
|
138
|
+
return true
|
|
139
|
+
end
|
|
140
|
+
return false
|
|
141
|
+
end
|
|
142
|
+
function PlayerProperty.prototype.get(self, player)
|
|
143
|
+
local ____table_PlayerPropertyPropertyKey_IS_CHANGED_BY_PLAYER_has_result_0
|
|
144
|
+
if self[2][player] ~= nil then
|
|
145
|
+
____table_PlayerPropertyPropertyKey_IS_CHANGED_BY_PLAYER_has_result_0 = self[1][player]
|
|
146
|
+
else
|
|
147
|
+
____table_PlayerPropertyPropertyKey_IS_CHANGED_BY_PLAYER_has_result_0 = self[0]
|
|
148
|
+
end
|
|
149
|
+
return ____table_PlayerPropertyPropertyKey_IS_CHANGED_BY_PLAYER_has_result_0
|
|
150
|
+
end
|
|
151
|
+
local NULL_VALUE = {}
|
|
152
|
+
local loadedValueById
|
|
153
|
+
local loadedValueByIdByPlayer = {}
|
|
154
|
+
local localValueById = {}
|
|
155
|
+
local persistentPropertyById = {}
|
|
156
|
+
local persistentPlayerPropertyById = {}
|
|
157
|
+
____exports.PersistentProperty = __TS__Class()
|
|
158
|
+
local PersistentProperty = ____exports.PersistentProperty
|
|
159
|
+
PersistentProperty.name = "PersistentProperty"
|
|
160
|
+
__TS__ClassExtends(PersistentProperty, ____exports.Property)
|
|
161
|
+
function PersistentProperty.prototype.____constructor(self, id, defaultValue, valueChangeEventListener)
|
|
162
|
+
PersistentProperty.____super.prototype.____constructor(self, defaultValue)
|
|
163
|
+
self.id = id
|
|
164
|
+
____require(not (persistentPropertyById[id] ~= nil) and not (persistentPlayerPropertyById[id] ~= nil))
|
|
165
|
+
persistentPropertyById[id] = self
|
|
166
|
+
if valueChangeEventListener ~= nil then
|
|
167
|
+
self.valueChangeEvent:addListener(valueChangeEventListener)
|
|
168
|
+
end
|
|
169
|
+
local value = loadedValueById and loadedValueById[id]
|
|
170
|
+
if value ~= nil then
|
|
171
|
+
local ____self_set_4 = self.set
|
|
172
|
+
local ____temp_3
|
|
173
|
+
if value == NULL_VALUE then
|
|
174
|
+
____temp_3 = nil
|
|
175
|
+
else
|
|
176
|
+
____temp_3 = value
|
|
177
|
+
end
|
|
178
|
+
____self_set_4(self, ____temp_3)
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
function PersistentProperty.prototype.reset(self)
|
|
182
|
+
if PersistentProperty.____super.prototype.reset(self) then
|
|
183
|
+
localValueById[self.id] = nil
|
|
184
|
+
savePropertyValues()
|
|
185
|
+
return true
|
|
186
|
+
end
|
|
187
|
+
return false
|
|
188
|
+
end
|
|
189
|
+
function PersistentProperty.prototype.set(self, value)
|
|
190
|
+
if PersistentProperty.____super.prototype.set(self, value) then
|
|
191
|
+
localValueById[self.id] = value == nil and NULL_VALUE or value
|
|
192
|
+
savePropertyValues()
|
|
193
|
+
return true
|
|
194
|
+
end
|
|
195
|
+
return false
|
|
196
|
+
end
|
|
197
|
+
____exports.PersistentPlayerProperty = __TS__Class()
|
|
198
|
+
local PersistentPlayerProperty = ____exports.PersistentPlayerProperty
|
|
199
|
+
PersistentPlayerProperty.name = "PersistentPlayerProperty"
|
|
200
|
+
__TS__ClassExtends(PersistentPlayerProperty, ____exports.PlayerProperty)
|
|
201
|
+
function PersistentPlayerProperty.prototype.____constructor(self, id, initialValue, valueChangeEventListener)
|
|
202
|
+
PersistentPlayerProperty.____super.prototype.____constructor(self, initialValue)
|
|
203
|
+
self.id = id
|
|
204
|
+
____require(not (persistentPropertyById[id] ~= nil) and not (persistentPlayerPropertyById[id] ~= nil))
|
|
205
|
+
persistentPlayerPropertyById[id] = self
|
|
206
|
+
if valueChangeEventListener ~= nil then
|
|
207
|
+
self.valueChangeEvent:addListener(valueChangeEventListener)
|
|
208
|
+
end
|
|
209
|
+
for ____, player in ipairs(Player.all) do
|
|
210
|
+
local ____opt_5 = loadedValueByIdByPlayer and loadedValueByIdByPlayer[player]
|
|
211
|
+
local value = ____opt_5 and ____opt_5[id]
|
|
212
|
+
if value ~= nil then
|
|
213
|
+
local ____self_set_10 = self.set
|
|
214
|
+
local ____temp_9
|
|
215
|
+
if value == NULL_VALUE then
|
|
216
|
+
____temp_9 = nil
|
|
217
|
+
else
|
|
218
|
+
____temp_9 = value
|
|
219
|
+
end
|
|
220
|
+
____self_set_10(self, player, ____temp_9)
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
function PersistentPlayerProperty.prototype.reset(self, player)
|
|
225
|
+
if PersistentPlayerProperty.____super.prototype.reset(self, player) then
|
|
226
|
+
if player.isLocal then
|
|
227
|
+
localValueById[self.id] = nil
|
|
228
|
+
end
|
|
229
|
+
savePropertyValues(player)
|
|
230
|
+
return true
|
|
231
|
+
end
|
|
232
|
+
return false
|
|
233
|
+
end
|
|
234
|
+
function PersistentPlayerProperty.prototype.set(self, player, value)
|
|
235
|
+
if PersistentPlayerProperty.____super.prototype.set(self, player, value) then
|
|
236
|
+
if player.isLocal then
|
|
237
|
+
localValueById[self.id] = value
|
|
238
|
+
end
|
|
239
|
+
savePropertyValues(player)
|
|
240
|
+
return true
|
|
241
|
+
end
|
|
242
|
+
return false
|
|
243
|
+
end
|
|
244
|
+
savePropertyValues = function(player)
|
|
245
|
+
if player ~= nil and not player.isLocal or loadedValueById == nil or loadedValueByIdByPlayer[Player["local"]] == nil then
|
|
246
|
+
return
|
|
247
|
+
end
|
|
248
|
+
local writer = __TS__New(BinaryWriter)
|
|
249
|
+
writer:writeUInt32(0)
|
|
250
|
+
local size = 0
|
|
251
|
+
for ____ in pairs(localValueById) do
|
|
252
|
+
size = size + 1
|
|
253
|
+
end
|
|
254
|
+
writer:writeUInt32(size)
|
|
255
|
+
for id, value in pairs(localValueById) do
|
|
256
|
+
writer:writeInt32(id)
|
|
257
|
+
if value == NULL_VALUE then
|
|
258
|
+
writer:writeUInt8(0)
|
|
259
|
+
elseif value == false then
|
|
260
|
+
writer:writeUInt8(1)
|
|
261
|
+
elseif value == true then
|
|
262
|
+
writer:writeUInt8(2)
|
|
263
|
+
elseif type(value) == "number" then
|
|
264
|
+
if math.type(value) == "integer" then
|
|
265
|
+
writer:writeUInt8(3)
|
|
266
|
+
writer:writeInt32(value)
|
|
267
|
+
else
|
|
268
|
+
writer:writeUInt8(4)
|
|
269
|
+
writer:writeFloat(value)
|
|
270
|
+
end
|
|
271
|
+
else
|
|
272
|
+
writer:writeUInt8(5)
|
|
273
|
+
writer:writeUInt32(#value)
|
|
274
|
+
writer:writeBytes(value)
|
|
275
|
+
end
|
|
276
|
+
end
|
|
277
|
+
file.write(
|
|
278
|
+
____exports.PersistentPropertiesConfig.defaultFileName,
|
|
279
|
+
base64.encode(lzw.compress(tostring(writer)))
|
|
280
|
+
)
|
|
281
|
+
end
|
|
282
|
+
local function loadPropertyValues(fileData, player)
|
|
283
|
+
do
|
|
284
|
+
local function ____catch(_)
|
|
285
|
+
return true, {}
|
|
286
|
+
end
|
|
287
|
+
local ____try, ____hasReturned, ____returnValue = pcall(function()
|
|
288
|
+
local valueById = {}
|
|
289
|
+
local reader = __TS__New(
|
|
290
|
+
BinaryReader,
|
|
291
|
+
lzw.decompress(base64.decode(fileData))
|
|
292
|
+
)
|
|
293
|
+
reader:readUInt32()
|
|
294
|
+
local size = reader:readUInt32()
|
|
295
|
+
for _ = 1, size do
|
|
296
|
+
local id = reader:readInt32()
|
|
297
|
+
local dataType = reader:readUInt8()
|
|
298
|
+
if dataType == 0 then
|
|
299
|
+
valueById[id] = NULL_VALUE
|
|
300
|
+
elseif dataType == 1 then
|
|
301
|
+
valueById[id] = false
|
|
302
|
+
elseif dataType == 2 then
|
|
303
|
+
valueById[id] = true
|
|
304
|
+
elseif dataType == 3 then
|
|
305
|
+
valueById[id] = reader:readInt32()
|
|
306
|
+
elseif dataType == 4 then
|
|
307
|
+
valueById[id] = reader:readFloat()
|
|
308
|
+
elseif dataType == 5 then
|
|
309
|
+
valueById[id] = reader:readBytes(reader:readUInt32())
|
|
310
|
+
end
|
|
311
|
+
end
|
|
312
|
+
for id, value in pairs(valueById) do
|
|
313
|
+
local persistentProperty = persistentPropertyById[id]
|
|
314
|
+
if persistentProperty ~= nil then
|
|
315
|
+
if not persistentProperty.isChanged then
|
|
316
|
+
local ____persistentProperty_set_12 = persistentProperty.set
|
|
317
|
+
local ____temp_11
|
|
318
|
+
if value == NULL_VALUE then
|
|
319
|
+
____temp_11 = nil
|
|
320
|
+
else
|
|
321
|
+
____temp_11 = value
|
|
322
|
+
end
|
|
323
|
+
____persistentProperty_set_12(persistentProperty, ____temp_11)
|
|
324
|
+
end
|
|
325
|
+
elseif player ~= nil then
|
|
326
|
+
local persistentPlayerProperty = persistentPlayerPropertyById[id]
|
|
327
|
+
if persistentPlayerProperty ~= nil then
|
|
328
|
+
if not persistentPlayerProperty:isChanged(player) then
|
|
329
|
+
local ____persistentPlayerProperty_set_15 = persistentPlayerProperty.set
|
|
330
|
+
local ____player_14 = player
|
|
331
|
+
local ____temp_13
|
|
332
|
+
if value == NULL_VALUE then
|
|
333
|
+
____temp_13 = nil
|
|
334
|
+
else
|
|
335
|
+
____temp_13 = value
|
|
336
|
+
end
|
|
337
|
+
____persistentPlayerProperty_set_15(persistentPlayerProperty, ____player_14, ____temp_13)
|
|
338
|
+
end
|
|
339
|
+
elseif player.isLocal then
|
|
340
|
+
localValueById[id] = value
|
|
341
|
+
end
|
|
342
|
+
else
|
|
343
|
+
localValueById[id] = value
|
|
344
|
+
end
|
|
345
|
+
end
|
|
346
|
+
return true, valueById
|
|
347
|
+
end)
|
|
348
|
+
if not ____try then
|
|
349
|
+
____hasReturned, ____returnValue = ____catch(____hasReturned)
|
|
350
|
+
end
|
|
351
|
+
if ____hasReturned then
|
|
352
|
+
return ____returnValue
|
|
353
|
+
end
|
|
354
|
+
end
|
|
355
|
+
end
|
|
356
|
+
Timer:run(function()
|
|
357
|
+
local data = file.read(____exports.PersistentPropertiesConfig.defaultFileName) or ""
|
|
358
|
+
loadedValueById = loadPropertyValues(data)
|
|
359
|
+
for ____, player in ipairs(Player.all) do
|
|
360
|
+
local ____self_16 = synchronize(player, data)
|
|
361
|
+
____self_16["then"](
|
|
362
|
+
____self_16,
|
|
363
|
+
function(____, synchronizedData)
|
|
364
|
+
loadedValueByIdByPlayer[player] = loadPropertyValues(synchronizedData, player)
|
|
365
|
+
savePropertyValues(player)
|
|
366
|
+
end,
|
|
367
|
+
function()
|
|
368
|
+
loadedValueByIdByPlayer[player] = {}
|
|
369
|
+
savePropertyValues(player)
|
|
370
|
+
end
|
|
371
|
+
)
|
|
372
|
+
end
|
|
373
|
+
end)
|
|
374
|
+
return ____exports
|