wowlab_engine_domain/dbc/semantics/
mechanics.rs1bitflags::bitflags! {
2 #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
4 pub struct MechanicMask: u64 {
5 const CHARM = 1 << 1;
6 const DISORIENTED = 1 << 2;
7 const DISARM = 1 << 3;
8 const DISTRACT = 1 << 4;
9 const FEAR = 1 << 5;
10 const GRIP = 1 << 6;
11 const ROOT = 1 << 7;
12 const SLOW_ATTACK = 1 << 8;
13 const SILENCE = 1 << 9;
14 const SLEEP = 1 << 10;
15 const SNARE = 1 << 11;
16 const STUN = 1 << 12;
17 const FREEZE = 1 << 13;
18 const KNOCKOUT = 1 << 14;
19 const BLEED = 1 << 15;
20 const BANDAGE = 1 << 16;
21 const POLYMORPH = 1 << 17;
22 const BANISH = 1 << 18;
23 const SHIELD = 1 << 19;
24 const SHACKLE = 1 << 20;
25 const MOUNT = 1 << 21;
26 const INFECTED = 1 << 22;
27 const TURN = 1 << 23;
28 const HORROR = 1 << 24;
29 const INVULNERABILITY = 1 << 25;
30 const INTERRUPT = 1 << 26;
31 const DAZE = 1 << 27;
32 const DISCOVERY = 1 << 28;
33 const IMMUNE_SHIELD = 1 << 29;
34 const SAPPED = 1 << 30;
35 const ENRAGED = 1 << 31;
36 const WOUNDED = 1 << 32;
37 const INFECTED_2 = 1 << 33;
38 const INFECTED_3 = 1 << 34;
39 const INFECTED_4 = 1 << 35;
40 const TAUNTED = 1 << 36;
41
42 const MOVEMENT_IMPAIRMENT_AND_LOSS_OF_CONTROL =
43 Self::CHARM.bits()
44 | Self::DISORIENTED.bits()
45 | Self::DISARM.bits()
46 | Self::FEAR.bits()
47 | Self::ROOT.bits()
48 | Self::SILENCE.bits()
49 | Self::SLEEP.bits()
50 | Self::SNARE.bits()
51 | Self::STUN.bits()
52 | Self::FREEZE.bits()
53 | Self::KNOCKOUT.bits()
54 | Self::POLYMORPH.bits()
55 | Self::BANISH.bits()
56 | Self::SHACKLE.bits()
57 | Self::TURN.bits()
58 | Self::HORROR.bits()
59 | Self::DAZE.bits()
60 | Self::SAPPED.bits();
61
62 const LOSS_OF_CONTROL =
63 Self::MOVEMENT_IMPAIRMENT_AND_LOSS_OF_CONTROL.bits()
64 & !Self::SNARE.bits()
65 & !Self::TURN.bits()
66 & !Self::DAZE.bits();
67 }
68}
69
70#[derive(Clone, Copy, Debug, Eq, PartialEq)]
72#[repr(i32)]
73#[non_exhaustive]
74pub enum Mechanic {
75 Charm = 1,
76 Disoriented = 2,
77 Disarm = 3,
78 Distract = 4,
79 Fear = 5,
80 Grip = 6,
81 Root = 7,
82 SlowAttack = 8,
83 Silence = 9,
84 Sleep = 10,
85 Snare = 11,
86 Stun = 12,
87 Freeze = 13,
88 Knockout = 14,
89 Bleed = 15,
90 Bandage = 16,
91 Polymorph = 17,
92 Banish = 18,
93 Shield = 19,
94 Shackle = 20,
95 Mount = 21,
96 Infected = 22,
97 Turn = 23,
98 Horror = 24,
99 Invulnerability = 25,
100 Interrupt = 26,
101 Daze = 27,
102 Discovery = 28,
103 ImmuneShield = 29,
104 Sapped = 30,
105 Enraged = 31,
106 Wounded = 32,
107 Infected2 = 33,
108 Infected3 = 34,
109 Infected4 = 35,
110 Taunted = 36,
111}
112
113impl Mechanic {
114 pub const ALL: [Self; 36] = [
115 Self::Charm,
116 Self::Disoriented,
117 Self::Disarm,
118 Self::Distract,
119 Self::Fear,
120 Self::Grip,
121 Self::Root,
122 Self::SlowAttack,
123 Self::Silence,
124 Self::Sleep,
125 Self::Snare,
126 Self::Stun,
127 Self::Freeze,
128 Self::Knockout,
129 Self::Bleed,
130 Self::Bandage,
131 Self::Polymorph,
132 Self::Banish,
133 Self::Shield,
134 Self::Shackle,
135 Self::Mount,
136 Self::Infected,
137 Self::Turn,
138 Self::Horror,
139 Self::Invulnerability,
140 Self::Interrupt,
141 Self::Daze,
142 Self::Discovery,
143 Self::ImmuneShield,
144 Self::Sapped,
145 Self::Enraged,
146 Self::Wounded,
147 Self::Infected2,
148 Self::Infected3,
149 Self::Infected4,
150 Self::Taunted,
151 ];
152
153 #[must_use]
154 pub fn from_dbc(raw: i32) -> Option<Self> {
155 let index = usize::try_from(raw.checked_sub(1)?).ok()?;
156
157 Self::ALL.get(index).copied()
158 }
159
160 #[must_use]
161 pub const fn mask(self) -> MechanicMask {
162 MechanicMask::from_bits_retain(1 << self as i32)
163 }
164}
165
166#[derive(Clone, Copy, Debug, Eq, PartialEq, num_enum::TryFromPrimitive)]
168#[repr(i32)]
169#[non_exhaustive]
170pub enum DispelType {
171 None = 0,
172 Magic = 1,
173 Curse = 2,
174 Disease = 3,
175 Poison = 4,
176 Stealth = 5,
177 Invisibility = 6,
178 All = 7,
179 NpcOnly = 8,
180 Enrage = 9,
181 ZulGurubTicket = 10,
182 OldUnused = 11,
183}