Agent

Struct Agent 

Source
#[repr(C)]
pub struct Agent<Kind = ()> { /* private fields */ }
Expand description

An agent.

Agents in arcdps are very versatile, as a lot of things end up being an “agent”. This includes:

  • Players
  • Bosses
  • Any additional mobs that spawn
  • Mesmer illusions
  • Ranger spirits, pets
  • Guardian spirit weapons

Generally, you can divide them into three kinds (AgentKind):

  • Player: All players themselves.
  • Character: Non-player mobs, including most bosses, “adds” and player-generated characters.
  • Gadget: Some additional gadgets, such as ley rifts, continuum split, …

All of these agents share some common fields, which are the ones accessible in Agent<Kind>. The kind can be retrieved using .kind(), which can be matched on.

§Obtaining an agent

The normal way to obtain the agents is to use the .agents() method on a Log, or one of the other accessor methods (like .players() or .agent_by_addr()).

In the cases where you already have a raw::Agent available, you can also convert it to an Agent by using the standard TryFrom/TryInto traits:

use std::convert::TryInto;
let raw_agent: raw::Agent = panic!();
let agent: Agent = raw_agent.try_into().unwrap();

Note that you can convert references as well, so if you plan on re-using the raw agent afterwards, you should opt for Agent::try_from(&raw_agent) instead.

§The Kind parameter

The type parameter is not actually used and only exists at the type level. It can be used to tag Agents containing a known kind. For example, Agent<Player> implements .player(), which returns a &Player directly (instead of a Option<&Player>). This works because such tagged Agents can only be constructed (safely) using .as_player(), .as_gadget() or .as_character(). This is useful since functions like Log::players, which already filter only players, don’t require the consumer to do another check/pattern match for the right agent kind.

The unit type () is used to tag Agents which contain an undetermined type, and it is the default if you write Agent without any parameters.

The downside is that methods which work on Agents theoretically should be generic over Kind. An escape hatch is the method .erase(), which erases the kind information and produces the default Agent<()>. Functions/methods that only take Agent<()> can therefore be used by any other agent as well.

Implementations§

Source§

impl<Kind> Agent<Kind>

Source

pub fn kind(&self) -> &AgentKind

The kind of this agent.

Source§

impl<Kind> Agent<Kind>

Source

pub fn addr(&self) -> u64

The address of this agent.

This is not actually the address of the in-memory Rust object, but rather a serialization detail of arcdps. You should consider this as an opaque number and only compare it to other agent addresses.

Source

pub fn toughness(&self) -> i16

The toughness of this agent.

This is not an absolute number, but a relative indicator that indicates this agent’s toughness relative to the other people in the squad.

0 means lowest toughness, 10 means highest toughness.

Source

pub fn concentration(&self) -> i16

The concentration of this agent.

This is not an absolute number, but a relative indicator that indicates this agent’s concentration relative to the other people in the squad.

0 means lowest concentration, 10 means highest concentration.

Source

pub fn healing(&self) -> i16

The healing power of this agent.

This is not an absolute number, but a relative indicator that indicates this agent’s healing power relative to the other people in the squad.

0 means lowest healing power, 10 means highest healing power.

Source

pub fn condition(&self) -> i16

The condition damage of this agent.

This is not an absolute number, but a relative indicator that indicates this agent’s condition damage relative to the other people in the squad.

0 means lowest condition damage, 10 means highest condition damage.

Source

pub fn instance_id(&self) -> u16

The instance ID of this agent.

Source

pub fn first_aware(&self) -> u64

The timestamp of the first event entry with this agent.

Source

pub fn last_aware(&self) -> u64

The timestamp of the last event entry with this agent.

Source

pub fn master_agent(&self) -> Option<u64>

The master agent’s address.

Source§

impl<Kind> Agent<Kind>

Source

pub fn erase(&self) -> &Agent

Erase any extra information about the contained agent kind.

Source

pub fn as_player(&self) -> Option<&Agent<Player>>

Try to convert this Agent to an Agent representing a Player.

Source

pub fn as_gadget(&self) -> Option<&Agent<Gadget>>

Try to convert this Agent to an Agent representing a Gadget.

Source

pub fn as_character(&self) -> Option<&Agent<Character>>

Try to convert this Agent to an Agent representing a Character.

Source§

impl Agent<Player>

Source

pub fn player(&self) -> &Player

Directly access the underlying player data.

Source

pub fn account_name(&self) -> &str

Shorthand to get the player’s account name.

Source

pub fn character_name(&self) -> &str

Shorthand to get the player’s character name.

Source

pub fn elite(&self) -> Option<EliteSpec>

Shorthand to get the player’s elite specialization.

Source

pub fn profession(&self) -> Profession

Shorthand to get the player’s profession.

Source

pub fn subgroup(&self) -> u8

Shorthand to get the player’s subgroup.

Source§

impl Agent<Gadget>

Source

pub fn gadget(&self) -> &Gadget

Directly access the underlying gadget data.

Source

pub fn id(&self) -> u16

Shorthand to get the gadget’s id.

Source

pub fn name(&self) -> &str

Shorthand to get the gadget’s name.

Source§

impl Agent<Character>

Source

pub fn character(&self) -> &Character

Directly access the underlying character data.

Source

pub fn id(&self) -> u16

Shorthand to get the character’s id.

Source

pub fn name(&self) -> &str

Shorthand to get the character’s name.

Trait Implementations§

Source§

impl<Kind: Clone> Clone for Agent<Kind>

Source§

fn clone(&self) -> Agent<Kind>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Kind: Debug> Debug for Agent<Kind>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Kind: Hash> Hash for Agent<Kind>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<Kind: PartialEq> PartialEq for Agent<Kind>

Source§

fn eq(&self, other: &Agent<Kind>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<&Agent> for Agent

Source§

fn try_from(raw_agent: &Agent) -> Result<Self, Self::Error>

Parse a raw agent.

Source§

type Error = EvtcError

The type returned in the event of a conversion error.
Source§

impl TryFrom<Agent> for Agent

Source§

fn try_from(raw_agent: Agent) -> Result<Self, Self::Error>

Convenience method to avoid manual borrowing.

Note that this conversion will consume the agent, so if you plan on re-using it, use the TryFrom<&raw::Agent> implementation that works with a reference.

Source§

type Error = EvtcError

The type returned in the event of a conversion error.
Source§

impl<Kind: Eq> Eq for Agent<Kind>

Source§

impl<Kind> StructuralPartialEq for Agent<Kind>

Auto Trait Implementations§

§

impl<Kind> Freeze for Agent<Kind>

§

impl<Kind> RefUnwindSafe for Agent<Kind>
where Kind: RefUnwindSafe,

§

impl<Kind> Send for Agent<Kind>
where Kind: Send,

§

impl<Kind> Sync for Agent<Kind>
where Kind: Sync,

§

impl<Kind> Unpin for Agent<Kind>
where Kind: Unpin,

§

impl<Kind> UnwindSafe for Agent<Kind>
where Kind: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.