blob: 37f65ab2cea495860ba399a1ac253549932d6c7b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
use azalea::{
ecs::prelude::*,
entity::{Dead, LocalEntity, Position, metadata::AbstractMonster},
prelude::*,
};
use crate::State;
pub fn tick(bot: Client, state: State) -> eyre::Result<()> {
if !state.killaura {
return Ok(());
}
if bot.has_attack_cooldown() {
return Ok(());
}
let bot_position = bot.eye_position()?;
let nearest_entity = bot.nearest_entity_by::<&Position, (
With<AbstractMonster>,
Without<LocalEntity>,
Without<Dead>,
)>(|position: &Position| {
let distance = bot_position.distance_to(**position);
distance < 4.
})?;
if let Some(nearest_entity) = nearest_entity {
println!("attacking {nearest_entity:?}");
nearest_entity.attack();
}
Ok(())
}
|