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