Merge branch 'crabman/basicmelee-hit-timing' into 'master'

Add hit_timing to BasicMelee

See merge request veloren/veloren!4193
This commit is contained in:
Samuel Keiffer 2023-11-27 21:47:30 +00:00
commit 3d9d3d9419
35 changed files with 52 additions and 6 deletions

View File

@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- A few new commands, `/tether`, `/destroy_tethers`, `/mount` and `/dismount`.
- A way to target non-player entities with commands. With rtsim_id: `rtsim@<id>`, with uid: `uid@<id>`.
- Shorthand in voxygen for specific entities in commands, some examples `@target`, `@mount`, `@viewpoint`.
- Added hit_timing to BasicMelee abilities
### Changed

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 0.4,
swing_duration: 0.2,
hit_timing: 0.8,
recover_duration: 0.4,
melee_constructor: (
kind: Stab(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 0.4,
swing_duration: 0.25,
hit_timing: 0.6,
recover_duration: 0.45,
melee_constructor: (
kind: Stab(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 0.5,
swing_duration: 0.1,
hit_timing: 0.5,
recover_duration: 0.5,
melee_constructor: (
kind: Slash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 1.2,
swing_duration: 0.1,
hit_timing: 0.4,
recover_duration: 1.0,
melee_constructor: (
kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 0.9,
swing_duration: 0.3,
hit_timing: 0.6,
recover_duration: 0.6,
melee_constructor: (
kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 1.6,
swing_duration: 0.1,
hit_timing: 0.6,
recover_duration: 1.0,
melee_constructor: (
kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 0.8,
swing_duration: 0.1,
hit_timing: 0.5,
recover_duration: 0.7,
melee_constructor: (
kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 0.7,
swing_duration: 0.15,
hit_timing: 0.7,
recover_duration: 0.6,
melee_constructor: (
kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 0.5,
swing_duration: 0.1,
hit_timing: 0.5,
recover_duration: 0.7,
melee_constructor: (
kind: Slash(
@ -21,4 +22,4 @@ BasicMelee(
multi_target: Some(Normal),
),
ori_modifier: 0.2,
)
)

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 0.4,
swing_duration: 0.1,
hit_timing: 0.5,
recover_duration: 0.8,
melee_constructor: (
kind: Slash(
@ -21,4 +22,4 @@ BasicMelee(
multi_target: Some(Normal),
),
ori_modifier: 1.0,
)
)

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 0.9,
swing_duration: 0.1,
hit_timing: 0.5,
recover_duration: 1.2,
melee_constructor: (
kind: Slash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 0.4,
swing_duration: 0.05,
hit_timing: 0.8,
recover_duration: 0.6,
melee_constructor: (
kind: Bash(

View File

@ -1,7 +1,8 @@
BasicMelee(
energy_cost: 0,
buildup_duration: 0.25,
buildup_duration: 0.5,
swing_duration: 0.3,
hit_timing: 0.5,
recover_duration: 1.0,
melee_constructor: (
kind: SonicWave(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 0.45,
swing_duration: 0.1,
hit_timing: 0.7,
recover_duration: 1.2,
melee_constructor: (
kind: Slash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 1.15,
swing_duration: 0.3,
hit_timing: 0.4,
recover_duration: 0.85,
melee_constructor: (
kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 0.2,
swing_duration: 0.3,
hit_timing: 0.5,
recover_duration: 0.1,
melee_constructor: (
kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 0.45,
swing_duration: 0.1,
hit_timing: 0.3,
recover_duration: 1.2,
melee_constructor: (
kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 0.5,
swing_duration: 0.1,
hit_timing: 0.4,
recover_duration: 0.5,
melee_constructor: (
kind: Slash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 0.9,
swing_duration: 0.3,
hit_timing: 0.6,
recover_duration: 0.6,
melee_constructor: (
kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 1.6,
swing_duration: 0.1,
hit_timing: 0.6,
recover_duration: 1.0,
melee_constructor: (
kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 1.2,
swing_duration: 0.1,
hit_timing: 0.8,
recover_duration: 2.0,
melee_constructor: (
kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 0.1,
swing_duration: 0.1,
hit_timing: 0.5,
recover_duration: 0.3,
melee_constructor: (
kind: Stab(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 0.0,
swing_duration: 0.1,
hit_timing: 0.0,
recover_duration: 0.9,
melee_constructor: (
kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 0.6,
swing_duration: 0.1,
hit_timing: 0.5,
recover_duration: 0.15,
melee_constructor: (
kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 0.3,
swing_duration: 0.05,
hit_timing: 0.8,
recover_duration: 0.45,
melee_constructor: (
kind: Slash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 0.6,
swing_duration: 0.1,
hit_timing: 0.5,
recover_duration: 0.45,
melee_constructor: (
kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 0.15,
swing_duration: 0.05,
hit_timing: 0.4,
recover_duration: 0.375,
melee_constructor: (
kind: Stab(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 0.25,
swing_duration: 0.05,
hit_timing: 0.5,
recover_duration: 0.075,
melee_constructor: (
kind: Stab(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 0.1,
swing_duration: 0.1,
hit_timing: 0.0,
recover_duration: 0.3,
melee_constructor: (
kind: Bash(

View File

@ -2,6 +2,7 @@ BasicMelee(
energy_cost: 0,
buildup_duration: 0.25,
swing_duration: 0.05,
hit_timing: 0.5,
recover_duration: 0.075,
melee_constructor: (
kind: Stab(

View File

@ -687,6 +687,7 @@ pub enum CharacterAbility {
energy_cost: f32,
buildup_duration: f32,
swing_duration: f32,
hit_timing: f32,
recover_duration: f32,
melee_constructor: MeleeConstructor,
ori_modifier: f32,
@ -1026,6 +1027,7 @@ impl Default for CharacterAbility {
energy_cost: 0.0,
buildup_duration: 0.25,
swing_duration: 0.25,
hit_timing: 0.5,
recover_duration: 0.5,
melee_constructor: MeleeConstructor {
kind: MeleeConstructorKind::Slash {
@ -1185,6 +1187,7 @@ impl CharacterAbility {
ref mut recover_duration,
ref mut melee_constructor,
ori_modifier: _,
hit_timing: _,
meta: _,
} => {
*buildup_duration /= stats.speed;
@ -2230,6 +2233,7 @@ impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState {
CharacterAbility::BasicMelee {
buildup_duration,
swing_duration,
hit_timing,
recover_duration,
melee_constructor,
ori_modifier,
@ -2239,6 +2243,7 @@ impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState {
static_data: basic_melee::StaticData {
buildup_duration: Duration::from_secs_f32(*buildup_duration),
swing_duration: Duration::from_secs_f32(*swing_duration),
hit_timing: hit_timing.clamp(0.0, 1.0),
recover_duration: Duration::from_secs_f32(*recover_duration),
melee_constructor: *melee_constructor,
ori_modifier: *ori_modifier,

View File

@ -23,6 +23,8 @@ pub struct StaticData {
pub swing_duration: Duration,
/// How long the state has until exiting
pub recover_duration: Duration,
/// At what fraction of swing_duration to make the hit
pub hit_timing: f32,
/// Used to construct the Melee attack
pub melee_constructor: MeleeConstructor,
/// Adjusts turning rate during the attack
@ -70,9 +72,13 @@ impl CharacterBehavior for Data {
}
},
StageSection::Action => {
if !self.exhausted {
if !self.exhausted
&& self.timer.as_secs_f32()
>= self.static_data.swing_duration.as_secs_f32()
* self.static_data.hit_timing
{
update.character = CharacterState::BasicMelee(Data {
timer: Duration::default(),
timer: tick_attack_or_default(data, self.timer, None),
exhausted: true,
..*self
});

View File

@ -223,7 +223,10 @@ impl<'a> System<'a> for Sys {
// Note: Don't use ori.look_vec() here, it leads to incorrect results for wide
// angle melee attacks
let precision_from_flank = combat::precision_mult_from_flank(
(pos_b.0 - pos.0).try_normalized().unwrap_or(ori.look_vec()),
(pos_b.0 - pos.0)
.with_z(0.0)
.try_normalized()
.unwrap_or(ori.look_vec()),
target_ori,
);

View File

@ -74,6 +74,7 @@ fn maps_basic_melee() {
static_data: states::basic_melee::StaticData {
buildup_duration: Duration::default(),
swing_duration: Duration::default(),
hit_timing: 0.0,
recover_duration: Duration::default(),
melee_constructor: melee::MeleeConstructor {
kind: melee::MeleeConstructorKind::Slash {