Made enemies sometimes roll

This commit is contained in:
Joshua Barretto 2019-08-03 13:31:40 +01:00
parent 51fa4f3cfc
commit 5e3e87f9c5

View File

@ -69,14 +69,10 @@ impl<'a> System<'a> for Sys {
let dist = Vec2::<f32>::from(target_pos.0 - pos.0).magnitude();
if target_stats.is_dead {
choose_new = true;
} else if dist < 1.5 {
// Get more distance
controller.move_dir =
Vec2::<f32>::from(target_pos.0 - pos.0).normalized() * -0.96;
} else if dist < 4.0 {
// Fight and slowly move closer
controller.move_dir =
Vec2::<f32>::from(target_pos.0 - pos.0).normalized() * 0.1;
Vec2::<f32>::from(target_pos.0 - pos.0).normalized() * 0.5;
if rand::random::<f32>() < 0.1 {
controller.attack = true;
@ -86,6 +82,10 @@ impl<'a> System<'a> for Sys {
} else if dist < SIGHT_DIST {
controller.move_dir =
Vec2::<f32>::from(target_pos.0 - pos.0).normalized() * 0.96;
if rand::random::<f32>() < 0.02 {
controller.roll = true;
}
} else {
choose_new = true;
}