evtc\event/category.rs
1use crate::{Activation, BuffRemove, Event, StateChange};
2
3#[cfg(feature = "serde")]
4use serde::{Deserialize, Serialize};
5
6#[cfg(feature = "strum")]
7use strum::{Display, EnumCount, EnumIter, IntoStaticStr, VariantNames};
8
9/// Possible [`Event`] categories.
10#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
11#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
12#[cfg_attr(
13 feature = "strum",
14 derive(Display, EnumCount, EnumIter, IntoStaticStr, VariantNames)
15)]
16pub enum EventCategory {
17 /// State change event.
18 ///
19 /// See variants of [`StateChange`] for details.
20 StateChange,
21
22 /// Activation (cast) event.
23 ///
24 /// `is_activation` contains [`Activation`] (except [`Activation::None`]).
25 ///
26 /// For [`Activation::Start`] and [`Activation::QuicknessUnused`]:
27 /// `value` contains the duration at which all "significant" effects associated with the cast have happened (for example damage hits).
28 /// `buff_dmg` contains the duration at which control is expected to be returned to the character (for example aftercasts).
29 ///
30 /// For [`Activation::CancelFire`] and [`Activation::CancelCancel`]:
31 /// `value` contains the time spent in animation.
32 /// `buff_dmg` contains the duration of the scaled (as if not affected) time spent.
33 ///
34 /// `dst_agent` contains x/y of target of skill effect.
35 /// `overstack_value` contains z of target of skill effect.
36 ///
37 /// All durations and times are given in milliseconds.
38 ///
39 /// For skill data see [`SkillInfo`](crate::skill::SkillInfo) and [`SkillTiming`](crate::skill::SkillTiming).
40 Activation,
41
42 /// Buff removed.
43 ///
44 /// `is_buffremove` contains [`BuffRemove`] (except [`BuffRemove::None`]).
45 /// `skill_id` contains the buff id.
46 /// `buff` will be non-zero.
47 ///
48 /// `src_agent` is agent that had buff removed.
49 /// `dst_agent` is the agent that caused the buff to be removed.
50 ///
51 /// `value` contains the remaining time on the removed buff calculated as duration.
52 /// `buff_dmg` contains the remaining time on the removed buff calculated as intensity
53 /// *Warning: this can overflow on [`BuffRemove::All`], use as sum check only!*
54 ///
55 /// For [`BuffRemove::All`] `result` contains the number of stacks removed
56 ///
57 /// For [`BuffRemove::Single`] `pad61` to `pad64` contains the buff instance id of buff removed.
58 ///
59 /// For buff data see [`BuffInfo`](crate::buff::BuffInfo) and [`BuffFormula`](crate::buff::BuffFormula).
60 BuffRemove,
61
62 /// Buff applied.
63 ///
64 /// `skill_id` contains the buff id.
65 /// `buff` will be non-zero.
66 ///
67 /// `value` contains the duration in milliseconds applied.
68 /// `pad61` to `pad64` contains the buff instance id of the buff applied.
69 /// `is_shields` contains the stack active status.
70 ///
71 /// If `is_offcycle == 0`, `overstack_value` contains the duration of the existing buff stack that is expected to be replaced.
72 /// If `is_offcycle != 0`, `overstack_value` contains the new duration of the existing buff stack and `value` contains the duration change (no new buff stack added).
73 ///
74 /// For buff data see [`BuffInfo`](crate::buff::BuffInfo) and [`BuffFormula`](crate::buff::BuffFormula).
75 BuffApply,
76
77 /// Buff damage.
78 ///
79 /// `skill_id` contains the buff id.
80 /// `buff` will be non-zero.
81 ///
82 /// `buff_dmg` contains the damage dealt in Arc's damage simulation.
83 /// If `is_offcycle == 0`, damage is accumulated by tick (for example Bleeding tick).
84 /// If `is_offcycle != 0`, damage is accumulated reactively (for example Confusion damage on skill use).
85 /// `result` contains `0` if expected to hit, `1` for invulnerability by buff and `2`/`3`/`4` for invulnerability by skill.
86 ///
87 /// For buff data see [`BuffInfo`](crate::buff::BuffInfo) and [`BuffFormula`](crate::buff::BuffFormula).
88 BuffDamage,
89
90 /// Direct damage strike.
91 ///
92 /// `value` contains the combined shield (barrier) and health damage dealt.
93 /// `overstack_value` contains the shield (barrier) damage dealt.
94 /// `is_offcycle == 1` if target is currently downed.
95 /// `result` contains [`Strike`](crate::Strike).
96 Strike,
97}
98
99impl From<&Event> for EventCategory {
100 #[inline]
101 fn from(event: &Event) -> Self {
102 let statechange = event.get_statechange();
103 if statechange == StateChange::None
104 || (statechange == StateChange::BuffInitial && event.buff != 18)
105 {
106 if event.get_activation() != Activation::None {
107 EventCategory::Activation
108 } else if event.get_buffremove() != BuffRemove::None {
109 EventCategory::BuffRemove
110 } else if event.buff != 0 {
111 if event.buff_dmg == 0 && event.value != 0 {
112 EventCategory::BuffApply
113 } else {
114 EventCategory::BuffDamage
115 }
116 } else {
117 EventCategory::Strike
118 }
119 } else {
120 EventCategory::StateChange
121 }
122 }
123}