mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Animation time for combo melee now resets between stages.
This commit is contained in:
parent
cf573a42bd
commit
aab56ea636
@ -2,9 +2,7 @@
|
||||
// version in voxygen\src\meta.rs in order to reset save files to being empty
|
||||
|
||||
use crate::{
|
||||
comp::{
|
||||
body::object, projectile, Body, CharacterAbility, Gravity, LightEmitter, Projectile,
|
||||
},
|
||||
comp::{body::object, projectile, Body, CharacterAbility, Gravity, LightEmitter, Projectile},
|
||||
states::combo_melee,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -28,7 +28,8 @@ pub struct Stage {
|
||||
pub base_recover_duration: Duration,
|
||||
}
|
||||
|
||||
/// A sequence of attacks that can incrementally become faster and more damaging.
|
||||
/// A sequence of attacks that can incrementally become faster and more
|
||||
/// damaging.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Data {
|
||||
/// Indicates what stage the combo is in
|
||||
@ -82,7 +83,11 @@ impl CharacterBehavior for Data {
|
||||
} else if !self.exhausted {
|
||||
// Hit attempt
|
||||
data.updater.insert(data.entity, Attacking {
|
||||
base_healthchange: -((self.stage_data[stage_index].max_damage.min(self.stage_data[stage_index].base_damage + self.combo / self.num_stages * self.stage_data[stage_index].damage_increase)) as i32),
|
||||
base_healthchange: -((self.stage_data[stage_index].max_damage.min(
|
||||
self.stage_data[stage_index].base_damage
|
||||
+ self.combo / self.num_stages
|
||||
* self.stage_data[stage_index].damage_increase,
|
||||
)) as i32),
|
||||
range: self.stage_data[stage_index].range,
|
||||
max_angle: self.stage_data[stage_index].angle.to_radians(),
|
||||
applied: false,
|
||||
@ -118,7 +123,9 @@ impl CharacterBehavior for Data {
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
});
|
||||
} else if self.timer < self.combo_duration + self.stage_data[stage_index].base_recover_duration {
|
||||
} else if self.timer
|
||||
< self.combo_duration + self.stage_data[stage_index].base_recover_duration
|
||||
{
|
||||
if data.inputs.primary.is_pressed() {
|
||||
update.character = CharacterState::ComboMelee(Data {
|
||||
stage: (self.stage % self.num_stages) + 1,
|
||||
@ -159,7 +166,10 @@ impl CharacterBehavior for Data {
|
||||
// Grant energy on successful hit
|
||||
if let Some(attack) = data.attacking {
|
||||
if attack.applied && attack.hit_count > 0 {
|
||||
let energy = self.max_energy_gain.min(self.initial_energy_gain + self.combo * self.energy_increase) as i32;
|
||||
let energy = self
|
||||
.max_energy_gain
|
||||
.min(self.initial_energy_gain + self.combo * self.energy_increase)
|
||||
as i32;
|
||||
data.updater.remove::<Attacking>(data.entity);
|
||||
update.energy.change_by(energy, EnergySource::HitEnemy);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ pub mod basic_ranged;
|
||||
pub mod boost;
|
||||
pub mod charged_ranged;
|
||||
pub mod climb;
|
||||
pub mod combo_melee;
|
||||
pub mod dance;
|
||||
pub mod dash_melee;
|
||||
pub mod equipping;
|
||||
@ -16,6 +17,5 @@ pub mod roll;
|
||||
pub mod sit;
|
||||
pub mod sneak;
|
||||
pub mod spin_melee;
|
||||
pub mod combo_melee;
|
||||
pub mod utils;
|
||||
pub mod wielding;
|
||||
|
@ -911,34 +911,46 @@ impl FigureMgr {
|
||||
skeleton_attr,
|
||||
)
|
||||
},
|
||||
CharacterState::ComboMelee(s) => match s.stage {
|
||||
1 => {
|
||||
anim::character::AlphaAnimation::update_skeleton(
|
||||
CharacterState::ComboMelee(s) => {
|
||||
let stage_index = (s.stage - 1) as usize;
|
||||
let stage_time = if !s.exhausted {
|
||||
s.timer.as_secs_f64()
|
||||
} else {
|
||||
s.timer.as_secs_f64()
|
||||
+ s.stage_data[stage_index]
|
||||
.base_buildup_duration
|
||||
.as_secs_f64()
|
||||
};
|
||||
let stage_progress = stage_time
|
||||
/ (s.stage_data[stage_index]
|
||||
.base_buildup_duration
|
||||
.as_secs_f64()
|
||||
+ s.stage_data[stage_index]
|
||||
.base_recover_duration
|
||||
.as_secs_f64());
|
||||
match s.stage {
|
||||
1 => anim::character::AlphaAnimation::update_skeleton(
|
||||
&target_base,
|
||||
(active_tool_kind, second_tool_kind, vel.0.magnitude(), time),
|
||||
state.state_time,
|
||||
stage_progress,
|
||||
&mut state_animation_rate,
|
||||
skeleton_attr,
|
||||
)
|
||||
},
|
||||
2 => {
|
||||
anim::character::SpinAnimation::update_skeleton(
|
||||
),
|
||||
2 => anim::character::SpinAnimation::update_skeleton(
|
||||
&target_base,
|
||||
(active_tool_kind, second_tool_kind, time),
|
||||
state.state_time,
|
||||
stage_progress,
|
||||
&mut state_animation_rate,
|
||||
skeleton_attr,
|
||||
)
|
||||
},
|
||||
_ => {
|
||||
anim::character::BetaAnimation::update_skeleton(
|
||||
),
|
||||
_ => anim::character::BetaAnimation::update_skeleton(
|
||||
&target_base,
|
||||
(active_tool_kind, second_tool_kind, vel.0.magnitude(), time),
|
||||
state.state_time,
|
||||
stage_progress,
|
||||
&mut state_animation_rate,
|
||||
skeleton_attr,
|
||||
)
|
||||
},
|
||||
),
|
||||
}
|
||||
},
|
||||
CharacterState::BasicBlock { .. } => {
|
||||
anim::character::BlockIdleAnimation::update_skeleton(
|
||||
|
Loading…
Reference in New Issue
Block a user