diff options
author | Daniel Schadt <kingdread@gmx.de> | 2020-07-24 14:23:53 +0200 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2020-07-24 14:23:53 +0200 |
commit | 71528905ed228750559a41144a2e0a95db3e6805 (patch) | |
tree | 4e46c6cbd3a3e83ab707e7156b345fbe7f3048ea /src/analyzers/raids/w6.rs | |
parent | 01354b0934409c355831bb4202f998fe5dbdc335 (diff) | |
parent | 9d27ec7034f9ad07d8a1d74ab30fdc470de4e02d (diff) | |
download | evtclib-71528905ed228750559a41144a2e0a95db3e6805.tar.gz evtclib-71528905ed228750559a41144a2e0a95db3e6805.tar.bz2 evtclib-71528905ed228750559a41144a2e0a95db3e6805.zip |
Merge branch 'analyzers'
This brings in proper fight outcome detection, which is nice and needed
for downstream applications (raidgrep/ezau).
Furthermore, this cleans up the CM detection a bit by moving away from
the "descriptive" trigger way to just having dynamically dispatched
methods for every log.
Diffstat (limited to 'src/analyzers/raids/w6.rs')
-rw-r--r-- | src/analyzers/raids/w6.rs | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/src/analyzers/raids/w6.rs b/src/analyzers/raids/w6.rs new file mode 100644 index 0000000..8701a63 --- /dev/null +++ b/src/analyzers/raids/w6.rs @@ -0,0 +1,149 @@ +//! Boss fight analyzers for Wing 6 (Mythwright Gambit) +use crate::{ + analyzers::{helpers, Analyzer, Outcome}, + gamedata::{KENUT_ID, NIKARE_ID}, + EventKind, Log, +}; + +pub const CA_CM_BUFF: u32 = 53_075; +pub const ZOMMOROS_ID: u16 = 21_118; + +/// Analyzer for the first fight of Wing 6, Conjured Amalgamate. +/// +/// The CM is detected by the presence of the buff that the player targeted by the laser has. +#[derive(Debug, Clone, Copy)] +pub struct ConjuredAmalgamate<'log> { + log: &'log Log, +} + +impl<'log> ConjuredAmalgamate<'log> { + /// Create a new [`ConjuredAmalgamate`] 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 { + ConjuredAmalgamate { log } + } +} + +impl<'log> Analyzer for ConjuredAmalgamate<'log> { + fn log(&self) -> &Log { + self.log + } + + fn is_cm(&self) -> bool { + helpers::buff_present(self.log, CA_CM_BUFF) + } + + fn outcome(&self) -> Option<Outcome> { + for event in self.log.events() { + if let EventKind::Spawn { agent_addr } = event.kind() { + if self + .log + .agent_by_addr(*agent_addr) + .and_then(|a| a.as_character()) + .map(|a| a.id() == ZOMMOROS_ID) + .unwrap_or(false) + { + return Some(Outcome::Success); + } + } + } + Some(Outcome::Failure) + } +} + +pub const LARGOS_CM_HEALTH: u64 = 19_200_000; + +/// Analyzer for the second fight of Wing 6, Largos Twins. +/// +/// The CM is detected by the boss's health, which is higher in the challenge mote. +#[derive(Debug, Clone, Copy)] +pub struct LargosTwins<'log> { + log: &'log Log, +} + +impl<'log> LargosTwins<'log> { + /// Create a new [`LargosTwins`] 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 { + LargosTwins { log } + } +} + +impl<'log> Analyzer for LargosTwins<'log> { + fn log(&self) -> &Log { + self.log + } + + fn is_cm(&self) -> bool { + helpers::boss_health(self.log) + .map(|h| h >= LARGOS_CM_HEALTH) + .unwrap_or(false) + } + + fn outcome(&self) -> Option<Outcome> { + let mut nikare_dead = false; + let mut kenut_dead = false; + + for event in self.log.events() { + if let EventKind::ChangeDead { agent_addr } = event.kind() { + let agent = if let Some(agent) = self + .log + .agent_by_addr(*agent_addr) + .and_then(|a| a.as_character()) + { + agent + } else { + continue; + }; + + if agent.id() == NIKARE_ID { + nikare_dead = true; + } else if agent.id() == KENUT_ID { + kenut_dead = true; + } + } + } + + Outcome::from_bool(kenut_dead && nikare_dead) + } +} + +pub const QADIM_CM_HEALTH: u64 = 21_100_000; + +/// Analyzer for the third fight of Wing 6, Qadim. +/// +/// The CM is detected by the boss's health, which is higher in the challenge mote. +#[derive(Debug, Clone, Copy)] +pub struct Qadim<'log> { + log: &'log Log, +} + +impl<'log> Qadim<'log> { + /// Create a new [`Qadim`] 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 { + Qadim { log } + } +} + +impl<'log> Analyzer for Qadim<'log> { + fn log(&self) -> &Log { + self.log + } + + fn is_cm(&self) -> bool { + helpers::boss_health(self.log) + .map(|h| h >= QADIM_CM_HEALTH) + .unwrap_or(false) + } + + fn outcome(&self) -> Option<Outcome> { + Outcome::from_bool(helpers::players_exit_after_boss(self.log)) + } +} |