evtc\skill/
activation.rs

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