evtc\buff/
damage.rs
1use crate::{
2 event::{impl_common, CommonEvent},
3 extract::Extract,
4 Event, EventCategory, TryExtract,
5};
6use num_enum::{FromPrimitive, IntoPrimitive};
7
8#[cfg(feature = "serde")]
9use serde::{Deserialize, Serialize};
10
11#[cfg(feature = "strum")]
12use strum::{Display, EnumCount, EnumIter, IntoStaticStr, VariantNames};
13
14#[derive(Debug, Clone)]
18#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
19pub struct BuffDamageEvent {
20 #[cfg_attr(feature = "serde", serde(flatten))]
22 pub common: CommonEvent,
23
24 pub buff: u8,
27
28 pub damage: i32,
30
31 pub cycle: BuffCycle,
33
34 pub result: BuffDamageResult,
36}
37
38impl_common!(BuffDamageEvent);
39
40impl Extract for BuffDamageEvent {
41 #[inline]
42 unsafe fn extract(event: &Event) -> Self {
43 Self {
44 common: event.into(),
45 buff: event.buff,
46 damage: event.buff_dmg,
47 cycle: event.is_offcycle.into(),
48 result: event.result.into(),
49 }
50 }
51}
52
53impl TryExtract for BuffDamageEvent {
54 #[inline]
55 fn can_extract(event: &Event) -> bool {
56 event.categorize() == EventCategory::BuffDamage
57 }
58}
59
60#[derive(
62 Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, IntoPrimitive, FromPrimitive,
63)]
64#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
65#[cfg_attr(
66 feature = "strum",
67 derive(Display, EnumCount, EnumIter, IntoStaticStr, VariantNames)
68)]
69#[repr(u8)]
70pub enum BuffDamageResult {
71 Hit = 0,
73
74 InvulnByBuff = 1,
76
77 InvulnBySkill1 = 2,
79
80 InvulnBySkill2 = 3,
82
83 InvulnBySkill3 = 4,
85
86 #[num_enum(catch_all)]
88 Unknown(u8),
89}
90
91#[derive(
93 Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, IntoPrimitive, FromPrimitive,
94)]
95#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96#[cfg_attr(
97 feature = "strum",
98 derive(Display, EnumCount, EnumIter, IntoStaticStr, VariantNames)
99)]
100#[repr(u8)]
101pub enum BuffCycle {
102 Cycle = 0,
104
105 NotCycle = 1,
107
108 NotCycleOrResist = 2,
110
111 NotCycleDmgToTargetOnHit = 3,
113
114 NotCycleDmgToSourceOnHit = 4,
116
117 NotCycleDmgToTargetOnStackRemove = 5,
119
120 #[num_enum(catch_all)]
122 Unknown(u8),
123}