mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Reverted changes to melee system that were added to when beam was initially in melee system.
This commit is contained in:
parent
46563e7008
commit
a679a34a7b
@ -8,7 +8,6 @@ use serde::{Deserialize, Serialize};
|
|||||||
use specs::{Component, FlaggedStorage, VecStorage};
|
use specs::{Component, FlaggedStorage, VecStorage};
|
||||||
use specs_idvs::IdvStorage;
|
use specs_idvs::IdvStorage;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use vek::Vec3;
|
|
||||||
|
|
||||||
/// Data returned from character behavior fn's to Character Behavior System.
|
/// Data returned from character behavior fn's to Character Behavior System.
|
||||||
pub struct StateUpdate {
|
pub struct StateUpdate {
|
||||||
@ -150,9 +149,6 @@ pub struct Attacking {
|
|||||||
pub applied: bool,
|
pub applied: bool,
|
||||||
pub hit_count: u32,
|
pub hit_count: u32,
|
||||||
pub knockback: f32,
|
pub knockback: f32,
|
||||||
pub is_melee: bool,
|
|
||||||
pub lifesteal_eff: f32,
|
|
||||||
pub look_dir: Option<Vec3<f32>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Component for Attacking {
|
impl Component for Attacking {
|
||||||
|
@ -63,9 +63,6 @@ impl CharacterBehavior for Data {
|
|||||||
applied: false,
|
applied: false,
|
||||||
hit_count: 0,
|
hit_count: 0,
|
||||||
knockback: self.knockback,
|
knockback: self.knockback,
|
||||||
is_melee: true,
|
|
||||||
lifesteal_eff: 0.0,
|
|
||||||
look_dir: None,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
update.character = CharacterState::BasicMelee(Data {
|
update.character = CharacterState::BasicMelee(Data {
|
||||||
|
@ -212,9 +212,6 @@ impl CharacterBehavior for Data {
|
|||||||
applied: false,
|
applied: false,
|
||||||
hit_count: 0,
|
hit_count: 0,
|
||||||
knockback: 0.0,
|
knockback: 0.0,
|
||||||
is_melee: true,
|
|
||||||
lifesteal_eff: 0.0,
|
|
||||||
look_dir: None,
|
|
||||||
});
|
});
|
||||||
>>>>>>> 8e6d0821c... Beams now have spherical hit detection.
|
>>>>>>> 8e6d0821c... Beams now have spherical hit detection.
|
||||||
|
|
||||||
|
@ -80,9 +80,6 @@ impl CharacterBehavior for Data {
|
|||||||
applied: false,
|
applied: false,
|
||||||
hit_count: 0,
|
hit_count: 0,
|
||||||
knockback: 25.0,
|
knockback: 25.0,
|
||||||
is_melee: true,
|
|
||||||
lifesteal_eff: 0.0,
|
|
||||||
look_dir: None,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
update.character = CharacterState::LeapMelee(Data {
|
update.character = CharacterState::LeapMelee(Data {
|
||||||
|
@ -153,9 +153,6 @@ impl CharacterBehavior for Data {
|
|||||||
applied: false,
|
applied: false,
|
||||||
hit_count: 0,
|
hit_count: 0,
|
||||||
knockback: 10.0,
|
knockback: 10.0,
|
||||||
is_melee: true,
|
|
||||||
lifesteal_eff: 0.0,
|
|
||||||
look_dir: None,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
CharacterState::TripleStrike(Data {
|
CharacterState::TripleStrike(Data {
|
||||||
|
@ -151,7 +151,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Weapon gives base damage
|
// Weapon gives base damage
|
||||||
let source = DamageSource::Melee;
|
let source = DamageSource::Energy;
|
||||||
|
|
||||||
let mut damage = Damage {
|
let mut damage = Damage {
|
||||||
healthchange: -(beam.damage as f32),
|
healthchange: -(beam.damage as f32),
|
||||||
|
@ -88,7 +88,12 @@ impl<'a> System<'a> for Sys {
|
|||||||
&bodies,
|
&bodies,
|
||||||
)
|
)
|
||||||
.join()
|
.join()
|
||||||
{
|
{
|
||||||
|
// 2D versions
|
||||||
|
let pos2 = Vec2::from(pos.0);
|
||||||
|
let pos_b2 = Vec2::<f32>::from(pos_b.0);
|
||||||
|
let ori2 = Vec2::from(*ori.0);
|
||||||
|
|
||||||
// Scales
|
// Scales
|
||||||
let scale = scale_maybe.map_or(1.0, |s| s.0);
|
let scale = scale_maybe.map_or(1.0, |s| s.0);
|
||||||
let scale_b = scale_b_maybe.map_or(1.0, |s| s.0);
|
let scale_b = scale_b_maybe.map_or(1.0, |s| s.0);
|
||||||
@ -97,26 +102,10 @@ impl<'a> System<'a> for Sys {
|
|||||||
// Check if it is a damaging hit
|
// Check if it is a damaging hit
|
||||||
if entity != b
|
if entity != b
|
||||||
&& !stats_b.is_dead
|
&& !stats_b.is_dead
|
||||||
&& ((attack.is_melee
|
// Spherical wedge shaped attack field
|
||||||
&& cylindrical_hit_detection(
|
&& pos.0.distance_squared(pos_b.0) < (rad_b + scale * attack.range).powi(2)
|
||||||
*pos,
|
&& ori2.angle_between(pos_b2 - pos2) < attack.max_angle + (rad_b / pos2.distance(pos_b2)).atan()
|
||||||
*ori,
|
|
||||||
*pos_b,
|
|
||||||
rad_b,
|
|
||||||
scale,
|
|
||||||
attack.range,
|
|
||||||
attack.max_angle,
|
|
||||||
))
|
|
||||||
|| (!attack.is_melee
|
|
||||||
&& spherical_hit_detection(
|
|
||||||
*pos,
|
|
||||||
*pos_b,
|
|
||||||
rad_b,
|
|
||||||
scale,
|
|
||||||
attack.range,
|
|
||||||
attack.max_angle,
|
|
||||||
attack.look_dir.unwrap_or(*ori.0),
|
|
||||||
)))
|
|
||||||
{
|
{
|
||||||
// See if entities are in the same group
|
// See if entities are in the same group
|
||||||
let same_group = groups
|
let same_group = groups
|
||||||
@ -139,10 +128,8 @@ impl<'a> System<'a> for Sys {
|
|||||||
// Weapon gives base damage
|
// Weapon gives base damage
|
||||||
let source = if is_heal {
|
let source = if is_heal {
|
||||||
DamageSource::Healing
|
DamageSource::Healing
|
||||||
} else if attack.is_melee {
|
|
||||||
DamageSource::Melee
|
|
||||||
} else {
|
} else {
|
||||||
DamageSource::Energy
|
DamageSource::Melee
|
||||||
};
|
};
|
||||||
let healthchange = if is_heal {
|
let healthchange = if is_heal {
|
||||||
attack.base_heal as f32
|
attack.base_heal as f32
|
||||||
@ -171,16 +158,6 @@ impl<'a> System<'a> for Sys {
|
|||||||
cause,
|
cause,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if attack.lifesteal_eff > 0.0 && is_damage {
|
|
||||||
server_emitter.emit(ServerEvent::Damage {
|
|
||||||
uid: *uid,
|
|
||||||
change: HealthChange {
|
|
||||||
amount: (-damage.healthchange * attack.lifesteal_eff)
|
|
||||||
as i32,
|
|
||||||
cause: HealthSource::Healing { by: Some(*uid) },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
attack.hit_count += 1;
|
attack.hit_count += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,35 +177,4 @@ impl<'a> System<'a> for Sys {
|
|||||||
std::sync::atomic::Ordering::Relaxed,
|
std::sync::atomic::Ordering::Relaxed,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cylindrical_hit_detection(
|
|
||||||
pos: Pos,
|
|
||||||
ori: Ori,
|
|
||||||
pos_b: Pos,
|
|
||||||
rad_b: f32,
|
|
||||||
scale: f32,
|
|
||||||
range: f32,
|
|
||||||
angle: f32,
|
|
||||||
) -> bool {
|
|
||||||
// 2D versions
|
|
||||||
let pos2 = Vec2::from(pos.0);
|
|
||||||
let pos_b2 = Vec2::<f32>::from(pos_b.0);
|
|
||||||
let ori2 = Vec2::from(*ori.0);
|
|
||||||
|
|
||||||
return pos.0.distance_squared(pos_b.0) < (rad_b + scale * range).powi(2)
|
|
||||||
&& ori2.angle_between(pos_b2 - pos2) < angle + (rad_b / pos2.distance(pos_b2)).atan();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn spherical_hit_detection(
|
|
||||||
pos: Pos,
|
|
||||||
pos_b: Pos,
|
|
||||||
rad_b: f32,
|
|
||||||
scale: f32,
|
|
||||||
range: f32,
|
|
||||||
angle: f32,
|
|
||||||
ori: Vec3<f32>,
|
|
||||||
) -> bool {
|
|
||||||
return pos.0.distance_squared(pos_b.0) < (rad_b + scale * range).powi(2)
|
|
||||||
&& ori.angle_between(pos_b.0 - pos.0) < angle + (rad_b / pos.0.distance(pos_b.0)).atan();
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user