mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Addressed review comments.
This commit is contained in:
parent
01d1e15be3
commit
6814ce8134
@ -1463,3 +1463,13 @@ pub fn compute_protection(
|
|||||||
.sum::<Option<f32>>()
|
.sum::<Option<f32>>()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Used to compute the precision multiplier achieved by flanking a target
|
||||||
|
pub fn precision_mult_from_flank(attack_dir: Vec3<f32>, target_ori: Option<&Ori>) -> Option<f32> {
|
||||||
|
let angle = target_ori.map(|t_ori| t_ori.look_dir().angle_between(attack_dir));
|
||||||
|
match angle {
|
||||||
|
Some(angle) if angle < FULL_FLANK_ANGLE => Some(1.0),
|
||||||
|
Some(angle) if angle < PARTIAL_FLANK_ANGLE => Some(0.5),
|
||||||
|
Some(_) | None => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -233,19 +233,10 @@ impl<'a> System<'a> for Sys {
|
|||||||
target,
|
target,
|
||||||
);
|
);
|
||||||
|
|
||||||
let precision_from_flank = {
|
let precision_from_flank = combat::precision_mult_from_flank(
|
||||||
let beam_dir = beam.bezier.ctrl - beam.bezier.start;
|
beam.bezier.ctrl - beam.bezier.start,
|
||||||
let angle = target_info.ori.map_or(std::f32::consts::PI, |t_ori| {
|
target_info.ori,
|
||||||
t_ori.look_dir().angle_between(beam_dir)
|
);
|
||||||
});
|
|
||||||
if angle < combat::FULL_FLANK_ANGLE {
|
|
||||||
Some(1.0)
|
|
||||||
} else if angle < combat::PARTIAL_FLANK_ANGLE {
|
|
||||||
Some(0.5)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let precision_from_time = {
|
let precision_from_time = {
|
||||||
if let Some(ticks) = beam.hit_durations.get(&target) {
|
if let Some(ticks) = beam.hit_durations.get(&target) {
|
||||||
@ -258,8 +249,6 @@ impl<'a> System<'a> for Sys {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Is there a more idiomatic way to do this (taking the max of 2
|
|
||||||
// options)?
|
|
||||||
let precision_mult = precision_from_flank
|
let precision_mult = precision_from_flank
|
||||||
.map(|flank| {
|
.map(|flank| {
|
||||||
precision_from_time.map_or(flank, |head: f32| head.max(flank))
|
precision_from_time.map_or(flank, |head: f32| head.max(flank))
|
||||||
|
@ -220,18 +220,8 @@ impl<'a> System<'a> for Sys {
|
|||||||
target,
|
target,
|
||||||
);
|
);
|
||||||
|
|
||||||
let precision_from_flank = {
|
let precision_from_flank =
|
||||||
let angle = target_ori.map_or(std::f32::consts::PI, |t_ori| {
|
combat::precision_mult_from_flank(*ori.look_dir(), target_ori);
|
||||||
t_ori.look_dir().angle_between(*ori.look_dir())
|
|
||||||
});
|
|
||||||
if angle < combat::FULL_FLANK_ANGLE {
|
|
||||||
Some(1.0)
|
|
||||||
} else if angle < combat::PARTIAL_FLANK_ANGLE {
|
|
||||||
Some(0.5)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let precision_from_poise = {
|
let precision_from_poise = {
|
||||||
if let Some(CharacterState::Stunned(data)) = target_char_state {
|
if let Some(CharacterState::Stunned(data)) = target_char_state {
|
||||||
@ -241,7 +231,6 @@ impl<'a> System<'a> for Sys {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Is there a more idiomatic way to do this (taking the max of 2 options)?
|
|
||||||
let precision_mult = precision_from_flank
|
let precision_mult = precision_from_flank
|
||||||
.map(|flank| {
|
.map(|flank| {
|
||||||
precision_from_poise.map_or(flank, |head: f32| head.max(flank))
|
precision_from_poise.map_or(flank, |head: f32| head.max(flank))
|
||||||
|
@ -346,20 +346,13 @@ fn dispatch_hit(
|
|||||||
.and_then(|cs| cs.attack_immunities())
|
.and_then(|cs| cs.attack_immunities())
|
||||||
.map_or(false, |i| i.projectiles);
|
.map_or(false, |i| i.projectiles);
|
||||||
|
|
||||||
let precision_from_flank = {
|
let precision_from_flank =
|
||||||
let angle = target_info.ori.map_or(std::f32::consts::PI, |t_ori| {
|
combat::precision_mult_from_flank(*projectile_dir, target_info.ori);
|
||||||
t_ori.look_dir().angle_between(*projectile_dir)
|
|
||||||
});
|
|
||||||
if angle < combat::FULL_FLANK_ANGLE {
|
|
||||||
Some(1.0)
|
|
||||||
} else if angle < combat::PARTIAL_FLANK_ANGLE {
|
|
||||||
Some(0.5)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let precision_from_head = {
|
let precision_from_head = {
|
||||||
|
// This performs a cylinder and line segment intersection check. The cylinder is
|
||||||
|
// the upper 10% of an entity's dimensions. The line segment is from the
|
||||||
|
// projectile's positions on the current and previous tick.
|
||||||
let curr_pos = projectile_info.pos.0;
|
let curr_pos = projectile_info.pos.0;
|
||||||
let last_pos = projectile_info.pos.0 - projectile_info.vel.0 * read_data.dt.0;
|
let last_pos = projectile_info.pos.0 - projectile_info.vel.0 * read_data.dt.0;
|
||||||
let vel = projectile_info.vel.0;
|
let vel = projectile_info.vel.0;
|
||||||
@ -405,7 +398,6 @@ fn dispatch_hit(
|
|||||||
if headshot { Some(1.0) } else { None }
|
if headshot { Some(1.0) } else { None }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Is there a more idiomatic way to do this (taking the max of 2 options)?
|
|
||||||
let precision_mult = precision_from_flank
|
let precision_mult = precision_from_flank
|
||||||
.map(|flank| precision_from_head.map_or(flank, |head: f32| head.max(flank)))
|
.map(|flank| precision_from_head.map_or(flank, |head: f32| head.max(flank)))
|
||||||
.or(precision_from_head);
|
.or(precision_from_head);
|
||||||
|
@ -1139,8 +1139,8 @@ impl<'a> Widget for ItemTooltip<'a> {
|
|||||||
.parent(id)
|
.parent(id)
|
||||||
.with_style(self.style.desc)
|
.with_style(self.style.desc)
|
||||||
.color(text_color)
|
.color(text_color)
|
||||||
.down_from(state.ids.stats[3], V_PAD_STATS)
|
.down_from(state.ids.stats[2], V_PAD_STATS)
|
||||||
.set(state.ids.stats[4], ui);
|
.set(state.ids.stats[3], ui);
|
||||||
|
|
||||||
// Energy Efficiency
|
// Energy Efficiency
|
||||||
let energy_eff_text = if is_primary {
|
let energy_eff_text = if is_primary {
|
||||||
@ -1161,8 +1161,8 @@ impl<'a> Widget for ItemTooltip<'a> {
|
|||||||
.parent(id)
|
.parent(id)
|
||||||
.with_style(self.style.desc)
|
.with_style(self.style.desc)
|
||||||
.color(text_color)
|
.color(text_color)
|
||||||
.down_from(state.ids.stats[4], V_PAD_STATS)
|
.down_from(state.ids.stats[3], V_PAD_STATS)
|
||||||
.set(state.ids.stats[5], ui);
|
.set(state.ids.stats[4], ui);
|
||||||
|
|
||||||
// Buff Strength
|
// Buff Strength
|
||||||
let buff_str_text = if is_primary {
|
let buff_str_text = if is_primary {
|
||||||
@ -1183,8 +1183,8 @@ impl<'a> Widget for ItemTooltip<'a> {
|
|||||||
.parent(id)
|
.parent(id)
|
||||||
.with_style(self.style.desc)
|
.with_style(self.style.desc)
|
||||||
.color(text_color)
|
.color(text_color)
|
||||||
.down_from(state.ids.stats[5], V_PAD_STATS)
|
.down_from(state.ids.stats[4], V_PAD_STATS)
|
||||||
.set(state.ids.stats[6], ui);
|
.set(state.ids.stats[5], ui);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
|
Loading…
Reference in New Issue
Block a user