Attack speed now scales with combo in combo melee.

This commit is contained in:
Sam 2020-09-11 14:24:55 -05:00
parent e54483d789
commit 2aac008b90
3 changed files with 42 additions and 29 deletions

View File

@ -92,7 +92,8 @@ pub enum CharacterAbility {
initial_energy_gain: u32,
max_energy_gain: u32,
energy_increase: u32,
combo_duration: Duration,
speed_increase: f32,
max_speed_increase: f32,
},
LeapMelee {
energy_cost: u32,
@ -361,7 +362,8 @@ impl From<&CharacterAbility> for CharacterState {
initial_energy_gain,
max_energy_gain,
energy_increase,
combo_duration,
speed_increase,
max_speed_increase,
} => CharacterState::ComboMelee(combo_melee::Data {
stage: 1,
num_stages: stage_data.len() as u32,
@ -370,10 +372,11 @@ impl From<&CharacterAbility> for CharacterState {
initial_energy_gain: *initial_energy_gain,
max_energy_gain: *max_energy_gain,
energy_increase: *energy_increase,
combo_duration: *combo_duration,
timer: Duration::default(),
stage_section: StageSection::Buildup,
next_stage: false,
speed_increase: *speed_increase,
max_speed_increase: *max_speed_increase,
}),
CharacterAbility::LeapMelee {
energy_cost: _,

View File

@ -121,12 +121,12 @@ impl Tool {
stage_data: vec![
combo_melee::Stage {
stage: 1,
base_damage: (30.0 * self.base_power()) as u32,
max_damage: (50.0 * self.base_power()) as u32,
base_damage: (100.0 * self.base_power()) as u32,
max_damage: (120.0 * self.base_power()) as u32,
damage_increase: (10.0 * self.base_power()) as u32,
knockback: 5.0,
range: 3.5,
angle: 45.0,
range: 4.0,
angle: 30.0,
base_buildup_duration: Duration::from_millis(500),
base_swing_duration: Duration::from_millis(200),
base_recover_duration: Duration::from_millis(400),
@ -134,12 +134,12 @@ impl Tool {
},
combo_melee::Stage {
stage: 2,
base_damage: (50.0 * self.base_power()) as u32,
max_damage: (80.0 * self.base_power()) as u32,
base_damage: (80.0 * self.base_power()) as u32,
max_damage: (110.0 * self.base_power()) as u32,
damage_increase: (15.0 * self.base_power()) as u32,
knockback: 5.0,
range: 3.5,
angle: 45.0,
angle: 180.0,
base_buildup_duration: Duration::from_millis(400),
base_swing_duration: Duration::from_millis(600),
base_recover_duration: Duration::from_millis(400),
@ -147,12 +147,12 @@ impl Tool {
},
combo_melee::Stage {
stage: 3,
base_damage: (70.0 * self.base_power()) as u32,
max_damage: (110.0 * self.base_power()) as u32,
base_damage: (130.0 * self.base_power()) as u32,
max_damage: (170.0 * self.base_power()) as u32,
damage_increase: (20.0 * self.base_power()) as u32,
knockback: 5.0,
range: 3.5,
angle: 45.0,
knockback: 7.5,
range: 6.0,
angle: 10.0,
base_buildup_duration: Duration::from_millis(500),
base_swing_duration: Duration::from_millis(200),
base_recover_duration: Duration::from_millis(300),
@ -162,7 +162,8 @@ impl Tool {
initial_energy_gain: 0,
max_energy_gain: 100,
energy_increase: 20,
combo_duration: Duration::from_millis(10),
speed_increase: 0.9,
max_speed_increase: 0.8,
},
DashMelee {
energy_cost: 200,

View File

@ -51,14 +51,16 @@ pub struct Data {
pub max_energy_gain: u32,
/// Energy gain increase per combo
pub energy_increase: u32,
/// Duration for the next stage to be activated
pub combo_duration: Duration,
/// Timer for each stage
pub timer: Duration,
/// Checks what section a stage is in
pub stage_section: StageSection,
/// Whether the state should go onto the next stage
pub next_stage: bool,
/// (100% - speed_increase) is percentage speed increases from current to max when combo increases
pub speed_increase: f32,
/// (100% + max_speed_increase) is the max attack speed
pub max_speed_increase: f32,
}
impl CharacterBehavior for Data {
@ -82,13 +84,14 @@ impl CharacterBehavior for Data {
initial_energy_gain: self.initial_energy_gain,
max_energy_gain: self.max_energy_gain,
energy_increase: self.energy_increase,
combo_duration: self.combo_duration,
timer: self
.timer
.checked_add(Duration::from_secs_f32(data.dt.0))
.checked_add(Duration::from_secs_f32((1.0 + self.max_speed_increase * (1.0 - self.speed_increase.powi((self.combo / self.num_stages) as i32))) * data.dt.0))
.unwrap_or_default(),
stage_section: self.stage_section,
next_stage: self.next_stage,
speed_increase: self.speed_increase,
max_speed_increase: self.max_speed_increase,
});
} else if self.stage_section == StageSection::Buildup {
// Transitions to swing section of stage
@ -100,10 +103,11 @@ impl CharacterBehavior for Data {
initial_energy_gain: self.initial_energy_gain,
max_energy_gain: self.max_energy_gain,
energy_increase: self.energy_increase,
combo_duration: self.combo_duration,
timer: Duration::default(),
stage_section: StageSection::Swing,
next_stage: self.next_stage,
speed_increase: self.speed_increase,
max_speed_increase: self.max_speed_increase,
});
// Hit attempt
@ -139,13 +143,14 @@ impl CharacterBehavior for Data {
initial_energy_gain: self.initial_energy_gain,
max_energy_gain: self.max_energy_gain,
energy_increase: self.energy_increase,
combo_duration: self.combo_duration,
timer: self
.timer
.checked_add(Duration::from_secs_f32(data.dt.0))
.checked_add(Duration::from_secs_f32((1.0 + self.max_speed_increase * (1.0 - self.speed_increase.powi((self.combo / self.num_stages) as i32))) * data.dt.0))
.unwrap_or_default(),
stage_section: self.stage_section,
next_stage: self.next_stage,
speed_increase: self.speed_increase,
max_speed_increase: self.max_speed_increase,
});
} else if self.stage_section == StageSection::Swing {
// Transitions to recover section of stage
@ -157,10 +162,11 @@ impl CharacterBehavior for Data {
initial_energy_gain: self.initial_energy_gain,
max_energy_gain: self.max_energy_gain,
energy_increase: self.energy_increase,
combo_duration: self.combo_duration,
timer: Duration::default(),
stage_section: StageSection::Recover,
next_stage: self.next_stage,
speed_increase: self.speed_increase,
max_speed_increase: self.max_speed_increase,
});
} else if self.stage_section == StageSection::Recover
&& self.timer < self.stage_data[stage_index].base_recover_duration
@ -176,13 +182,14 @@ impl CharacterBehavior for Data {
initial_energy_gain: self.initial_energy_gain,
max_energy_gain: self.max_energy_gain,
energy_increase: self.energy_increase,
combo_duration: self.combo_duration,
timer: self
.timer
.checked_add(Duration::from_secs_f32(data.dt.0))
.checked_add(Duration::from_secs_f32((1.0 + self.max_speed_increase * (1.0 - self.speed_increase.powi((self.combo / self.num_stages) as i32))) * data.dt.0))
.unwrap_or_default(),
stage_section: self.stage_section,
next_stage: true,
speed_increase: self.speed_increase,
max_speed_increase: self.max_speed_increase,
});
} else {
update.character = CharacterState::ComboMelee(Data {
@ -193,13 +200,14 @@ impl CharacterBehavior for Data {
initial_energy_gain: self.initial_energy_gain,
max_energy_gain: self.max_energy_gain,
energy_increase: self.energy_increase,
combo_duration: self.combo_duration,
timer: self
.timer
.checked_add(Duration::from_secs_f32(data.dt.0))
.checked_add(Duration::from_secs_f32((1.0 + self.max_speed_increase * (1.0 - self.speed_increase.powi((self.combo / self.num_stages) as i32))) * data.dt.0))
.unwrap_or_default(),
stage_section: self.stage_section,
next_stage: self.next_stage,
speed_increase: self.speed_increase,
max_speed_increase: self.max_speed_increase,
});
}
} else if self.next_stage {
@ -212,10 +220,11 @@ impl CharacterBehavior for Data {
initial_energy_gain: self.initial_energy_gain,
max_energy_gain: self.max_energy_gain,
energy_increase: self.energy_increase,
combo_duration: self.combo_duration,
timer: Duration::default(),
stage_section: StageSection::Buildup,
next_stage: false,
speed_increase: self.speed_increase,
max_speed_increase: self.max_speed_increase,
});
} else {
// Done