Merge branch 'holychowders/fix_agents_not_responding_to_sound' into 'master'

Fix agents not hearing sounds due to reduced `listen_dist`, caused by commit `a6955e5af`.

See merge request veloren/veloren!3353
This commit is contained in:
Marcel 2022-05-05 09:20:13 +00:00
commit 005b69edc5
2 changed files with 4 additions and 9 deletions

View File

@ -282,7 +282,7 @@ impl<'a> From<&'a Body> for Psyche {
},
},
sight_dist: 40.0,
listen_dist: 5.0,
listen_dist: 30.0,
aggro_dist: match body {
Body::Humanoid(_) => Some(20.0),
_ => None, // Always aggressive if detected

View File

@ -1576,18 +1576,13 @@ impl<'a> AgentData<'a> {
})
};
// TODO: This is a temporary hack. Remove this once footsteps are emitted and
// agents are capable of detecting when someone is directly behind them.
let within_listen_dist = |e_pos: &Pos| {
let listen_dist = agent.psyche.listen_dist;
e_pos.0.distance_squared(self.pos.0) < listen_dist.powi(2)
};
let can_sense_directly_near =
{ |e_pos: &Pos| e_pos.0.distance_squared(self.pos.0) < 5_f32.powi(2) };
let is_detected = |entity: EcsEntity, e_pos: &Pos| {
let chance = thread_rng().gen_bool(0.3);
(within_listen_dist(e_pos) && chance)
(can_sense_directly_near(e_pos) && chance)
|| self.can_see_entity(agent, controller, entity, e_pos, read_data)
};