From 1a465ee75229d1268f20f2739ba29c4f84f70e7f Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Mon, 23 Apr 2018 15:14:35 +0200 Subject: add basic translation to more readable events This basically implements the "event logic" as described in the README, though it produces easier-to-digest events. The test binary show 0 failed events on an example log, but of course, not all mechanics are used there, and the parsing logic may very well contain some errors. --- src/raw/types.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/raw') diff --git a/src/raw/types.rs b/src/raw/types.rs index f94c4c2..f616398 100644 --- a/src/raw/types.rs +++ b/src/raw/types.rs @@ -1,4 +1,4 @@ -use std::fmt; +use std::{self, fmt}; /// The "friend or foe" enum. #[repr(C)] @@ -234,6 +234,29 @@ pub struct Agent { pub name: [u8; 64], } +impl Agent { + /// Checks whether this agent is a gadget. + /// + /// Gadgets are entities spawned by some skills, like the "Binding Roots" + /// spawned by Entangle. + pub fn is_gadget(&self) -> bool { + self.is_elite == std::u32::MAX && (self.prof & 0xffff0000) == 0xffff0000 + } + + /// Checks whether this agent is a character. + /// + /// Characters are entities like clones, pets, minions, spirits, but also + /// minis. + pub fn is_character(&self) -> bool { + self.is_elite == std::u32::MAX && (self.prof & 0xffff0000) != 0xffff0000 + } + + /// Checks whether this agent is a player. + pub fn is_player(&self) -> bool { + self.is_elite != std::u32::MAX + } +} + impl fmt::Debug for Agent { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( -- cgit v1.2.3