aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/analyzers/fractals.rs105
-rw-r--r--src/analyzers/mod.rs1
-rw-r--r--src/gamedata.rs10
3 files changed, 112 insertions, 4 deletions
diff --git a/src/analyzers/fractals.rs b/src/analyzers/fractals.rs
index 69a908a..637096a 100644
--- a/src/analyzers/fractals.rs
+++ b/src/analyzers/fractals.rs
@@ -1,16 +1,117 @@
//! Analyzers for (challenge mote) fractal encounters.
use crate::{
analyzers::{helpers, Analyzer, Outcome},
- Log,
+ Boss, EventKind, Log,
};
+/// The ID of the invulnerability buff that Ai gets when she has been defeated.
+pub const AI_INVULNERABILITY_ID: u32 = 895;
+/// The ID of the skill with which we determine when Ai has phased.
+pub const AI_PHASE_SKILL: u32 = 53_569;
+/// The ID of the skill with which we determine Ai has the dark phase fight.
+pub const AI_HAS_DARK_MODE_SKILL: u32 = 61_356;
+
+/// Gets the timestamp when the second phase of Ai starts.
+///
+/// If the log is missing dark phase, `None` is returned.
+///
+/// If the whole log is in dark phase, `Some(0)` is returned.
+fn get_dark_phase_start(log: &Log) -> Option<u64> {
+ // Determine if we even have a dark phase.
+ if !log.events().iter().any(|event| {
+ if let EventKind::SkillUse { skill_id, .. } = event.kind() {
+ *skill_id == AI_HAS_DARK_MODE_SKILL
+ } else {
+ false
+ }
+ }) {
+ return None;
+ };
+
+ // If we are here, either the whole log is in dark mode, or we phased.
+ let mut dark_phase_start = None;
+ for event in log.events() {
+ if let EventKind::SkillUse { skill_id, .. } = event.kind() {
+ if *skill_id == AI_PHASE_SKILL {
+ dark_phase_start = Some(event.time());
+ }
+ }
+ }
+
+ dark_phase_start.or(Some(0))
+}
+
+/// Analyzer for the fight of 100 CM, Ai, Keeper of the Peak.
+///
+/// This fight is special in that it consists of two phases, and the bosses each count as "success"
+/// when they reach 1% health, i.e. they don't die.
+#[derive(Debug, Clone, Copy)]
+pub struct Ai<'log> {
+ log: &'log Log,
+}
+
+impl<'log> Ai<'log> {
+ /// Create a new [`Ai`] analyzer for the given log.
+ ///
+ /// **Do not** use this method unless you know what you are doing. Instead, rely on
+ /// [`Log::analyzer`]!
+ pub fn new(log: &'log Log) -> Self {
+ Ai { log }
+ }
+}
+
+impl<'log> Analyzer for Ai<'log> {
+ fn log(&self) -> &Log {
+ self.log
+ }
+
+ fn is_cm(&self) -> bool {
+ // We assume that every Ai log is from CM, like the other fractal logs.
+ true
+ }
+
+ fn outcome(&self) -> Option<Outcome> {
+ let dark_phase_start = get_dark_phase_start(self.log);
+ if dark_phase_start.is_none() {
+ return Some(Outcome::Failure);
+ }
+
+ let dark_phase_start = dark_phase_start.unwrap();
+
+ for event in self.log.events() {
+ // Make sure we only count the invulnerability in dark phase
+ if event.time() < dark_phase_start {
+ continue;
+ }
+ if let EventKind::BuffApplication {
+ buff_id,
+ destination_agent_addr,
+ ..
+ } = event.kind()
+ {
+ let agent = self
+ .log
+ .agent_by_addr(*destination_agent_addr)
+ .and_then(|a| a.as_character());
+ if let Some(c) = agent {
+ if c.id() == Boss::Ai as u16 && *buff_id == AI_INVULNERABILITY_ID {
+ return Some(Outcome::Success);
+ }
+ }
+ }
+ }
+
+ Some(Outcome::Failure)
+ }
+}
+
/// Health threshold for Skorvald to be detected as Challenge Mote.
pub const SKORVALD_CM_HEALTH: u64 = 5_551_340;
/// Character IDs for the anomalies in Skorvald's Challenge Mote.
pub static SKORVALD_CM_ANOMALY_IDS: &[u16] = &[17_599, 17_673, 17_770, 17_851];
-/// Analyzer for the first boss of 100 CM, Skorvald.
+/// Analyzer for the first boss of 99 CM, Skorvald.
///
/// The CM was detected by the boss's health, which was higher in the challenge mote.
///
diff --git a/src/analyzers/mod.rs b/src/analyzers/mod.rs
index d6315f3..28724a2 100644
--- a/src/analyzers/mod.rs
+++ b/src/analyzers/mod.rs
@@ -107,6 +107,7 @@ pub fn for_log<'l>(log: &'l Log) -> Option<Box<dyn Analyzer + 'l>> {
Boss::CardinalSabir => Some(Box::new(raids::CardinalSabir::new(log))),
Boss::QadimThePeerless => Some(Box::new(raids::QadimThePeerless::new(log))),
+ Boss::Ai => Some(Box::new(fractals::Ai::new(log))),
Boss::Skorvald => Some(Box::new(fractals::Skorvald::new(log))),
Boss::Artsariiv | Boss::Arkk | Boss::MAMA | Boss::Siax | Boss::Ensolyss => {
Some(Box::new(fractals::GenericFractal::new(log)))
diff --git a/src/gamedata.rs b/src/gamedata.rs
index 775cf30..392bd01 100644
--- a/src/gamedata.rs
+++ b/src/gamedata.rs
@@ -51,12 +51,15 @@ pub enum Boss {
CardinalSabir = 0x55CC,
QadimThePeerless = 0x55F0,
- // 100 CM
+ // 100 CM (Sunqua Peak)
+ Ai = 0x5AD6,
+
+ // 99 CM (Shattered Observatory)
Skorvald = 0x44E0,
Artsariiv = 0x461D,
Arkk = 0x455F,
- // 99 CM
+ // 98 CM (Nightmare)
MAMA = 0x427D,
Siax = 0x4284,
Ensolyss = 0x4234,
@@ -112,6 +115,8 @@ impl FromStr for Boss {
"sabir" | "cardinal sabir" => Ok(Boss::CardinalSabir),
"qadimp" | "peerless qadim" | "qadim the peerless" => Ok(Boss::QadimThePeerless),
+ "ai" | "ai keeper of the peak" => Ok(Boss::Ai),
+
"skorvald" => Ok(Boss::Skorvald),
"artsariiv" => Ok(Boss::Artsariiv),
"arkk" => Ok(Boss::Arkk),
@@ -153,6 +158,7 @@ impl Display for Boss {
Boss::CardinalAdina => "Cardinal Adina",
Boss::CardinalSabir => "Cardinal Sabir",
Boss::QadimThePeerless => "Qadim the Peerless",
+ Boss::Ai => "Ai Keeper of the Peak",
Boss::Skorvald => "Skorvald the Shattered",
Boss::Artsariiv => "Artsariiv",
Boss::Arkk => "Arkk",