1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
#pragma once
#include "StarDamageTypes.hpp"
#include "StarWorldGeometry.hpp"
#include "StarStatusTypes.hpp"
namespace Star {
struct DamageSource {
typedef MVariant<PolyF, Line2F> DamageArea;
typedef MVariant<float, Vec2F> Knockback;
DamageSource();
DamageSource(Json const& v);
DamageSource(DamageType damageType,
DamageArea damageArea,
float damage,
bool trackSourceEntity,
EntityId sourceEntityId,
EntityDamageTeam team,
Maybe<String> damageRepeatGroup,
Maybe<float> damageRepeatTimeout,
String damageSourceKind,
List<EphemeralStatusEffect> statusEffects,
Knockback knockback,
bool rayCheck);
Json toJson() const;
DamageSource& translate(Vec2F const& position);
bool intersectsWithPoly(WorldGeometry const& worldGeometry, PolyF const& poly) const;
Vec2F knockbackMomentum(WorldGeometry const& worldGeometry, Vec2F const& targetCenter) const;
bool operator==(DamageSource const& rhs) const;
DamageType damageType;
DamageArea damageArea;
float damage;
bool trackSourceEntity;
// The originating entity for the damage, which can be different than the
// actual causing entity. Optional, defaults to NullEntityId.
EntityId sourceEntityId;
EntityDamageTeam team;
// Applying damage will block other DamageSources with the same
// damageRepeatGroup from applying damage until the timeout expires, to
// prevent damages being applied every tick. This is optional, and if it is
// omitted then the repeat group will instead be based on the causing entity
// id.
Maybe<String> damageRepeatGroup;
// Can override the default repeat damage timeout with a custom timeout.
Maybe<float> damageRepeatTimeout;
String damageSourceKind;
List<EphemeralStatusEffect> statusEffects;
// Either directionless knockback momentum or directional knockback momentum
Knockback knockback;
// Should a collision check from the source entity to the impact center be
// peformed before applying the damage?
bool rayCheck;
};
DataStream& operator<<(DataStream& ds, DamageSource const& damageSource);
DataStream& operator>>(DataStream& ds, DamageSource& damageSource);
struct DamageRequest {
DamageRequest();
DamageRequest(Json const& v);
DamageRequest(HitType hitType,
DamageType type,
float damage,
Vec2F const& knockbackMomentum,
EntityId sourceEntityId,
String const& damageSourceKind,
List<EphemeralStatusEffect> const& statusEffects);
Json toJson() const;
HitType hitType;
DamageType damageType;
float damage;
Vec2F knockbackMomentum;
// May be different than the entity that actually caused damage, for example,
// a player firing a projectile.
EntityId sourceEntityId;
String damageSourceKind;
List<EphemeralStatusEffect> statusEffects;
};
DataStream& operator<<(DataStream& ds, DamageRequest const& damageRequest);
DataStream& operator>>(DataStream& ds, DamageRequest& damageRequest);
struct DamageNotification {
DamageNotification();
DamageNotification(Json const& v);
DamageNotification(EntityId sourceEntityId,
EntityId targetEntityId,
Vec2F position,
float damageDealt,
float healthLost,
HitType hitType,
String damageSourceKind,
String targetMaterialKind);
Json toJson() const;
EntityId sourceEntityId;
EntityId targetEntityId;
Vec2F position;
float damageDealt;
float healthLost;
HitType hitType;
String damageSourceKind;
String targetMaterialKind;
};
DataStream& operator<<(DataStream& ds, DamageNotification const& damageNotification);
DataStream& operator>>(DataStream& ds, DamageNotification& damageNotification);
}
|