evtc\skill/
activation.rs

1use crate::{
2    AgentId, Event, EventCategory, Position, TryExtract,
3    extract::{Extract, transmute_field},
4};
5use num_enum::{FromPrimitive, IntoPrimitive};
6
7#[cfg(feature = "serde")]
8use serde::{Deserialize, Serialize};
9
10#[cfg(feature = "strum")]
11use strum::{Display, EnumCount, EnumIter, IntoStaticStr, VariantNames};
12
13/// Activation (skill cast) event.
14///
15/// Only animated skill casts are captured by ArcDPS.
16#[derive(Debug, Clone)]
17#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
18pub struct ActivationEvent {
19    /// Time of registering the activation.
20    pub time: u64,
21
22    /// Agent casting the skill.
23    pub agent: AgentId,
24
25    /// Id of casted skill.
26    pub skill_id: u32,
27
28    /// Kind of activation state change.
29    pub activation: Activation,
30
31    /// Activation duration.
32    pub duration: i32,
33
34    /// Scaled activation duration.
35    pub scaled_duration: i32,
36
37    /// Target location, if applicable.
38    pub target: Position,
39}
40
41impl Extract for ActivationEvent {
42    #[inline]
43    unsafe fn extract(event: &Event) -> Self {
44        let [x, y] = transmute_field!(event.dst_agent as [f32; 2]);
45        let z = f32::from_bits(event.overstack_value);
46        Self {
47            time: event.time,
48            agent: AgentId::from_src(event),
49            skill_id: event.skill_id,
50            activation: event.get_activation(),
51            duration: event.value,
52            scaled_duration: event.buff_dmg,
53            target: Position::new(x, y, z),
54        }
55    }
56}
57
58impl TryExtract for ActivationEvent {
59    #[inline]
60    fn can_extract(event: &Event) -> bool {
61        event.categorize() == EventCategory::Activation
62    }
63}
64
65/// Skill activation (cast).
66///
67/// *Arc calls this "combat activation".*
68#[derive(
69    Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, IntoPrimitive, FromPrimitive,
70)]
71#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
72#[cfg_attr(
73    feature = "strum",
74    derive(Display, EnumCount, EnumIter, IntoStaticStr, VariantNames)
75)]
76#[repr(u8)]
77pub enum Activation {
78    /// Not used, different kind of event.
79    None = 0,
80
81    /// Started skill/animation activation.
82    Start = 1,
83
84    /// Unused as of 5th November 2019.
85    QuicknessUnused = 2,
86
87    /// Stopped skill activation with reaching tooltip time.
88    CancelFire = 3,
89
90    /// Stopped skill activation without reaching tooltip time.
91    CancelCancel = 4,
92
93    /// Animation completed fully.
94    Reset = 5,
95
96    /// Unknown or invalid.
97    #[num_enum(catch_all)]
98    Unknown(u8),
99}
100
101/// Skill animation stop (UNOFFICIAL).
102///
103/// Present in `result` for activation cancels.
104#[derive(
105    Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, IntoPrimitive, FromPrimitive,
106)]
107#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
108#[cfg_attr(
109    feature = "strum",
110    derive(Display, EnumCount, EnumIter, IntoStaticStr, VariantNames)
111)]
112#[repr(u8)]
113pub enum AnimationStop {
114    None = 0,
115    Instant = 1,
116    SecondUse = 2,
117    Transition = 3,
118    Partial = 4,
119    Ended = 5,
120    Cancel = 6,
121    StowedChange = 7,
122    Interrupt = 8,
123    Death = 9,
124    Downed = 10,
125    CrowdControl = 11,
126    MoveBehind = 12,
127    MoveSkill = 13,
128    MoveDodge = 14,
129    MoveStop = 15,
130
131    /// Unknown or invalid.
132    #[num_enum(catch_all)]
133    Unknown(u8),
134}