mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'zesterer/small-fixes' into 'master'
Made orientation change with move_dir, added a small amount of knockback, orientation lerp, better enemy combat, improved healthbar placement See merge request veloren/veloren!399
This commit is contained in:
commit
295674d95a
@ -74,7 +74,7 @@ impl<'a> System<'a> for Sys {
|
||||
controller.move_dir =
|
||||
Vec2::<f32>::from(target_pos.0 - pos.0).normalized() * 0.5;
|
||||
|
||||
if rand::random::<f32>() < 0.1 {
|
||||
if rand::random::<f32>() < 0.05 {
|
||||
controller.attack = true;
|
||||
} else {
|
||||
controller.attack = false;
|
||||
|
@ -54,7 +54,8 @@ impl<'a> System<'a> for Sys {
|
||||
stat_b
|
||||
.health
|
||||
.change_by(-10, HealthSource::Attack { by: *uid }); // TODO: variable damage and weapon
|
||||
vel_b.0.z = 4.0;
|
||||
vel_b.0 += (pos_b.0 - pos.0).normalized() * 5.0;
|
||||
vel_b.0.z = 10.0;
|
||||
let _ = force_updates.insert(b, ForceUpdate);
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +109,19 @@ impl<'a> System<'a> for Sys {
|
||||
}
|
||||
_ => 0.0,
|
||||
};
|
||||
|
||||
// Set direction based on move direction when on the ground
|
||||
let ori_dir = if a.gliding || a.rolling {
|
||||
Vec2::from(vel.0)
|
||||
} else {
|
||||
move_dir.0
|
||||
};
|
||||
if ori_dir.magnitude_squared() > 0.0001
|
||||
&& (ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared()
|
||||
> 0.001
|
||||
{
|
||||
ori.0 = vek::ops::Slerp::slerp(ori.0, ori_dir.into(), 5.0 * dt.0);
|
||||
}
|
||||
}
|
||||
|
||||
// Jump
|
||||
@ -132,15 +145,6 @@ impl<'a> System<'a> for Sys {
|
||||
rollings.remove(entity);
|
||||
}
|
||||
}
|
||||
|
||||
// Set direction based on velocity when on the ground
|
||||
if Vec2::<f32>::from(vel.0).magnitude_squared() > 0.0001 {
|
||||
ori.0 = Lerp::lerp(
|
||||
ori.0,
|
||||
vel.0.normalized() * Vec3::new(1.0, 1.0, 0.0),
|
||||
10.0 * dt.0,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -268,6 +268,8 @@ impl<'a> System<'a> for Sys {
|
||||
|
||||
if diff.magnitude_squared() > 0.0
|
||||
&& diff.magnitude_squared() < collision_dist.powf(2.0)
|
||||
&& pos.0.z + 1.6 * scale > pos_other.0.z
|
||||
&& pos.0.z < pos_other.0.z + 1.6 * scale_other
|
||||
{
|
||||
vel.0 +=
|
||||
Vec3::from(diff.normalized()) * (collision_dist - diff.magnitude()) * 5.0;
|
||||
|
@ -349,7 +349,8 @@ impl Hud {
|
||||
let ecs = client.state().ecs();
|
||||
let pos = ecs.read_storage::<comp::Pos>();
|
||||
let stats = ecs.read_storage::<comp::Stats>();
|
||||
let player = ecs.read_storage::<comp::Player>();
|
||||
let players = ecs.read_storage::<comp::Player>();
|
||||
let scales = ecs.read_storage::<comp::Scale>();
|
||||
let entities = ecs.entities();
|
||||
let me = client.entity();
|
||||
let view_distance = client.view_distance().unwrap_or(1);
|
||||
@ -389,17 +390,17 @@ impl Hud {
|
||||
.set(self.ids.crosshair_inner, ui_widgets);
|
||||
|
||||
// Render Name Tags
|
||||
for (pos, name) in (&entities, &pos, &stats, player.maybe())
|
||||
for (pos, name, scale) in (&entities, &pos, &stats, players.maybe(), scales.maybe())
|
||||
.join()
|
||||
.filter(|(entity, _, stats, _)| *entity != me && !stats.is_dead)
|
||||
.filter(|(entity, _, stats, _, _)| *entity != me && !stats.is_dead)
|
||||
// Don't process nametags outside the vd (visibility further limited by ui backend)
|
||||
.filter(|(_, pos, _, _)| {
|
||||
.filter(|(_, pos, _, _, _)| {
|
||||
(pos.0 - player_pos)
|
||||
.map2(TerrainChunkSize::SIZE, |d, sz| d.abs() as f32 / sz as f32)
|
||||
.magnitude()
|
||||
< view_distance as f32
|
||||
})
|
||||
.map(|(_, pos, stats, player)| {
|
||||
.map(|(_, pos, stats, player, scale)| {
|
||||
// TODO: This is temporary
|
||||
// If the player used the default character name display their name instead
|
||||
let name = if stats.name == "Character Name" {
|
||||
@ -407,9 +408,11 @@ impl Hud {
|
||||
} else {
|
||||
&stats.name
|
||||
};
|
||||
(pos.0, name)
|
||||
(pos.0, name, scale)
|
||||
})
|
||||
{
|
||||
let scale = scale.map(|s| s.0).unwrap_or(1.0);
|
||||
|
||||
let id = name_id_walker.next(
|
||||
&mut self.ids.name_tags,
|
||||
&mut ui_widgets.widget_id_generator(),
|
||||
@ -418,27 +421,29 @@ impl Hud {
|
||||
.font_size(20)
|
||||
.color(Color::Rgba(0.61, 0.61, 0.89, 1.0))
|
||||
.x_y(0.0, 0.0)
|
||||
.position_ingame(pos + Vec3::new(0.0, 0.0, 3.0))
|
||||
.position_ingame(pos + Vec3::new(0.0, 0.0, 1.5 * scale + 1.5))
|
||||
.resolution(100.0)
|
||||
.set(id, ui_widgets);
|
||||
}
|
||||
|
||||
// Render Health Bars
|
||||
for (_entity, pos, stats) in (&entities, &pos, &stats)
|
||||
for (_entity, pos, stats, scale) in (&entities, &pos, &stats, scales.maybe())
|
||||
.join()
|
||||
.filter(|(entity, _, stats)| {
|
||||
.filter(|(entity, _, stats, _)| {
|
||||
*entity != me
|
||||
&& !stats.is_dead
|
||||
&& stats.health.current() != stats.health.maximum()
|
||||
})
|
||||
// Don't process health bars outside the vd (visibility further limited by ui backend)
|
||||
.filter(|(_, pos, _)| {
|
||||
.filter(|(_, pos, _, _)| {
|
||||
(pos.0 - player_pos)
|
||||
.map2(TerrainChunkSize::SIZE, |d, sz| d.abs() as f32 / sz as f32)
|
||||
.magnitude()
|
||||
< view_distance as f32
|
||||
})
|
||||
{
|
||||
let scale = scale.map(|s| s.0).unwrap_or(1.0);
|
||||
|
||||
let back_id = health_back_id_walker.next(
|
||||
&mut self.ids.health_bar_backs,
|
||||
&mut ui_widgets.widget_id_generator(),
|
||||
@ -450,7 +455,7 @@ impl Hud {
|
||||
// Background
|
||||
Rectangle::fill_with([120.0, 8.0], Color::Rgba(0.3, 0.3, 0.3, 0.5))
|
||||
.x_y(0.0, -25.0)
|
||||
.position_ingame(pos.0 + Vec3::new(0.0, 0.0, 3.0))
|
||||
.position_ingame(pos.0 + Vec3::new(0.0, 0.0, 1.5 * scale + 1.5))
|
||||
.resolution(100.0)
|
||||
.set(back_id, ui_widgets);
|
||||
|
||||
@ -463,7 +468,7 @@ impl Hud {
|
||||
HP_COLOR,
|
||||
)
|
||||
.x_y(0.0, -25.0)
|
||||
.position_ingame(pos.0 + Vec3::new(0.0, 0.0, 3.0))
|
||||
.position_ingame(pos.0 + Vec3::new(0.0, 0.0, 1.5 * scale + 1.5))
|
||||
.resolution(100.0)
|
||||
.set(bar_id, ui_widgets);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user