Single target melee attacks now hit the closest target instead of a random target.

This commit is contained in:
Sam 2022-02-17 20:32:27 -05:00
parent 1e0dfe003d
commit c09e858cba
4 changed files with 5 additions and 1 deletions

1
Cargo.lock generated
View File

@ -6854,6 +6854,7 @@ version = "0.10.0"
dependencies = [
"hashbrown 0.12.3",
"indexmap",
"itertools",
"ordered-float 3.1.0",
"rand 0.8.5",
"rayon",

View File

@ -1051,7 +1051,7 @@ pub fn handle_dodge_interrupt(
// Check that the input used to enter current character state (if there was one)
// is not pressed
if input_override
.or(data.character.ability_info().map(|a| a.input))
.or_else(|| data.character.ability_info().map(|a| a.input))
.map_or(true, |input| !input_is_pressed(data, input))
{
// If there is a stage section, only roll during

View File

@ -20,6 +20,7 @@ rayon = "1.5"
tracing = { version = "0.1", default-features = false }
vek = { version = "0.15.8", features = ["serde"] }
ordered-float = { version = "3", default-features = false }
itertools = "0.10"
# Data structures
hashbrown = { version = "0.12", features = ["rayon", "serde", "nightly"] }

View File

@ -13,6 +13,7 @@ use common::{
GroupTarget,
};
use common_ecs::{Job, Origin, Phase, System};
use itertools::Itertools;
use specs::{
shred::ResourceId, Entities, Join, Read, ReadStorage, SystemData, World, WriteStorage,
};
@ -111,6 +112,7 @@ impl<'a> System<'a> for Sys {
&read_data.uids,
)
.join()
.sorted_by_key(|(_, pos_b, _, _, _)| pos_b.0.distance_squared(pos.0) as u32)
{
// Unless the melee attack can hit multiple targets, stop the attack if it has
// already hit 1 target