Pfau/combat

This commit is contained in:
Monty Marz 2019-08-03 21:11:57 +00:00 committed by Joshua Barretto
parent c9f1a793db
commit d180c47edc
3 changed files with 5 additions and 5 deletions

View File

@ -69,7 +69,7 @@ impl<'a> System<'a> for Sys {
let dist = Vec2::<f32>::from(target_pos.0 - pos.0).magnitude(); let dist = Vec2::<f32>::from(target_pos.0 - pos.0).magnitude();
if target_stats.is_dead { if target_stats.is_dead {
choose_new = true; choose_new = true;
} else if dist < 4.0 { } else if dist < 6.0 {
// Fight and slowly move closer // Fight and slowly move closer
controller.move_dir = controller.move_dir =
Vec2::<f32>::from(target_pos.0 - pos.0).normalized() * 0.5; Vec2::<f32>::from(target_pos.0 - pos.0).normalized() * 0.5;

View File

@ -54,8 +54,8 @@ impl<'a> System<'a> for Sys {
stat_b stat_b
.health .health
.change_by(-10, HealthSource::Attack { by: *uid }); // TODO: variable damage and weapon .change_by(-10, HealthSource::Attack { by: *uid }); // TODO: variable damage and weapon
vel_b.0 += (pos_b.0 - pos.0).normalized() * 5.0; vel_b.0 += (pos_b.0 - pos.0).normalized() * 2.0;
vel_b.0.z = 10.0; vel_b.0.z = 2.0;
let _ = force_updates.insert(b, ForceUpdate); let _ = force_updates.insert(b, ForceUpdate);
} }
} }

View File

@ -264,7 +264,7 @@ impl<'a> System<'a> for Sys {
let scale_other = scale_other.map(|s| s.0).unwrap_or(1.0); let scale_other = scale_other.map(|s| s.0).unwrap_or(1.0);
let diff = Vec2::<f32>::from(pos.0 - pos_other.0); let diff = Vec2::<f32>::from(pos.0 - pos_other.0);
let collision_dist = 0.3 * (scale + scale_other); let collision_dist = 0.95 * (scale + scale_other);
if diff.magnitude_squared() > 0.0 if diff.magnitude_squared() > 0.0
&& diff.magnitude_squared() < collision_dist.powf(2.0) && diff.magnitude_squared() < collision_dist.powf(2.0)
@ -272,7 +272,7 @@ impl<'a> System<'a> for Sys {
&& pos.0.z < pos_other.0.z + 1.6 * scale_other && pos.0.z < pos_other.0.z + 1.6 * scale_other
{ {
vel.0 += vel.0 +=
Vec3::from(diff.normalized()) * (collision_dist - diff.magnitude()) * 5.0; Vec3::from(diff.normalized()) * (collision_dist - diff.magnitude()) * 1.0;
} }
} }
} }