mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Initial implementation of new dash melee.
This commit is contained in:
parent
abcd0af1e3
commit
04af75bf8d
@ -3,7 +3,7 @@ use crate::{
|
|||||||
item::{armor::Protection, Item, ItemKind},
|
item::{armor::Protection, Item, ItemKind},
|
||||||
Body, CharacterState, EnergySource, Gravity, LightEmitter, Projectile, StateUpdate,
|
Body, CharacterState, EnergySource, Gravity, LightEmitter, Projectile, StateUpdate,
|
||||||
},
|
},
|
||||||
states::*,
|
states::{utils::StageSection, *},
|
||||||
sys::character_behavior::JoinData,
|
sys::character_behavior::JoinData,
|
||||||
};
|
};
|
||||||
use arraygen::Arraygen;
|
use arraygen::Arraygen;
|
||||||
@ -72,9 +72,19 @@ pub enum CharacterAbility {
|
|||||||
},
|
},
|
||||||
DashMelee {
|
DashMelee {
|
||||||
energy_cost: u32,
|
energy_cost: u32,
|
||||||
buildup_duration: Duration,
|
|
||||||
recover_duration: Duration,
|
|
||||||
base_damage: u32,
|
base_damage: u32,
|
||||||
|
max_damage: u32,
|
||||||
|
base_knockback: f32,
|
||||||
|
max_knockback: f32,
|
||||||
|
range: f32,
|
||||||
|
angle: f32,
|
||||||
|
energy_drain: u32,
|
||||||
|
forward_speed: f32,
|
||||||
|
buildup_duration: Duration,
|
||||||
|
charge_duration: Duration,
|
||||||
|
infinite_charge: bool,
|
||||||
|
swing_duration: Duration,
|
||||||
|
recover_duration: Duration,
|
||||||
},
|
},
|
||||||
BasicBlock,
|
BasicBlock,
|
||||||
Roll,
|
Roll,
|
||||||
@ -310,15 +320,36 @@ impl From<&CharacterAbility> for CharacterState {
|
|||||||
}),
|
}),
|
||||||
CharacterAbility::DashMelee {
|
CharacterAbility::DashMelee {
|
||||||
energy_cost: _,
|
energy_cost: _,
|
||||||
buildup_duration,
|
|
||||||
recover_duration,
|
|
||||||
base_damage,
|
base_damage,
|
||||||
|
max_damage,
|
||||||
|
base_knockback,
|
||||||
|
max_knockback,
|
||||||
|
range,
|
||||||
|
angle,
|
||||||
|
energy_drain,
|
||||||
|
forward_speed,
|
||||||
|
buildup_duration,
|
||||||
|
charge_duration,
|
||||||
|
infinite_charge,
|
||||||
|
swing_duration,
|
||||||
|
recover_duration,
|
||||||
} => CharacterState::DashMelee(dash_melee::Data {
|
} => CharacterState::DashMelee(dash_melee::Data {
|
||||||
initialize: true,
|
|
||||||
exhausted: false,
|
|
||||||
buildup_duration: *buildup_duration,
|
|
||||||
recover_duration: *recover_duration,
|
|
||||||
base_damage: *base_damage,
|
base_damage: *base_damage,
|
||||||
|
max_damage: *max_damage,
|
||||||
|
base_knockback: *base_knockback,
|
||||||
|
max_knockback: *max_knockback,
|
||||||
|
range: *range,
|
||||||
|
angle: *angle,
|
||||||
|
energy_drain: *energy_drain,
|
||||||
|
forward_speed: *forward_speed,
|
||||||
|
buildup_duration: *buildup_duration,
|
||||||
|
charge_duration: *charge_duration,
|
||||||
|
charge_duration_attained: Duration::default(),
|
||||||
|
infinite_charge: *infinite_charge,
|
||||||
|
swing_duration: *swing_duration,
|
||||||
|
recover_duration: *recover_duration,
|
||||||
|
timer: Duration::default(),
|
||||||
|
stage_section: StageSection::Buildup,
|
||||||
}),
|
}),
|
||||||
CharacterAbility::BasicBlock => CharacterState::BasicBlock,
|
CharacterAbility::BasicBlock => CharacterState::BasicBlock,
|
||||||
CharacterAbility::Roll => CharacterState::Roll(roll::Data {
|
CharacterAbility::Roll => CharacterState::Roll(roll::Data {
|
||||||
@ -341,7 +372,7 @@ impl From<&CharacterAbility> for CharacterState {
|
|||||||
energy_increase: *energy_increase,
|
energy_increase: *energy_increase,
|
||||||
combo_duration: *combo_duration,
|
combo_duration: *combo_duration,
|
||||||
timer: Duration::default(),
|
timer: Duration::default(),
|
||||||
stage_section: wielding::StageSection::Buildup,
|
stage_section: StageSection::Buildup,
|
||||||
next_stage: false,
|
next_stage: false,
|
||||||
}),
|
}),
|
||||||
CharacterAbility::LeapMelee {
|
CharacterAbility::LeapMelee {
|
||||||
|
@ -121,9 +121,9 @@ impl Tool {
|
|||||||
stage_data: vec![
|
stage_data: vec![
|
||||||
combo_melee::Stage {
|
combo_melee::Stage {
|
||||||
stage: 1,
|
stage: 1,
|
||||||
base_damage: 30,
|
base_damage: (30.0 * self.base_power()) as u32,
|
||||||
max_damage: 50,
|
max_damage: (50.0 * self.base_power()) as u32,
|
||||||
damage_increase: 10,
|
damage_increase: (10.0 * self.base_power()) as u32,
|
||||||
knockback: 5.0,
|
knockback: 5.0,
|
||||||
range: 3.5,
|
range: 3.5,
|
||||||
angle: 45.0,
|
angle: 45.0,
|
||||||
@ -134,9 +134,9 @@ impl Tool {
|
|||||||
},
|
},
|
||||||
combo_melee::Stage {
|
combo_melee::Stage {
|
||||||
stage: 2,
|
stage: 2,
|
||||||
base_damage: 50,
|
base_damage: (50.0 * self.base_power()) as u32,
|
||||||
max_damage: 80,
|
max_damage: (80.0 * self.base_power()) as u32,
|
||||||
damage_increase: 15,
|
damage_increase: (15.0 * self.base_power()) as u32,
|
||||||
knockback: 5.0,
|
knockback: 5.0,
|
||||||
range: 3.5,
|
range: 3.5,
|
||||||
angle: 45.0,
|
angle: 45.0,
|
||||||
@ -147,9 +147,9 @@ impl Tool {
|
|||||||
},
|
},
|
||||||
combo_melee::Stage {
|
combo_melee::Stage {
|
||||||
stage: 3,
|
stage: 3,
|
||||||
base_damage: 70,
|
base_damage: (70.0 * self.base_power()) as u32,
|
||||||
max_damage: 110,
|
max_damage: (110.0 * self.base_power()) as u32,
|
||||||
damage_increase: 20,
|
damage_increase: (20.0 * self.base_power()) as u32,
|
||||||
knockback: 5.0,
|
knockback: 5.0,
|
||||||
range: 3.5,
|
range: 3.5,
|
||||||
angle: 45.0,
|
angle: 45.0,
|
||||||
@ -165,10 +165,20 @@ impl Tool {
|
|||||||
combo_duration: Duration::from_millis(10),
|
combo_duration: Duration::from_millis(10),
|
||||||
},
|
},
|
||||||
DashMelee {
|
DashMelee {
|
||||||
energy_cost: 700,
|
energy_cost: 100,
|
||||||
buildup_duration: Duration::from_millis(500),
|
base_damage: (60.0 * self.base_power()) as u32,
|
||||||
recover_duration: Duration::from_millis(500),
|
max_damage: (180.0 * self.base_power()) as u32,
|
||||||
base_damage: (120.0 * self.base_power()) as u32,
|
base_knockback: 5.0,
|
||||||
|
max_knockback: 10.0,
|
||||||
|
range: 5.0,
|
||||||
|
angle: 45.0,
|
||||||
|
energy_drain: 100,
|
||||||
|
forward_speed: 2.5,
|
||||||
|
buildup_duration: Duration::from_millis(250),
|
||||||
|
charge_duration: Duration::from_millis(2000),
|
||||||
|
infinite_charge: true,
|
||||||
|
swing_duration: Duration::from_millis(100),
|
||||||
|
recover_duration: Duration::from_millis(300),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
Axe(_) => vec![
|
Axe(_) => vec![
|
||||||
@ -254,23 +264,14 @@ impl Tool {
|
|||||||
max_projectile_speed: 500.0,
|
max_projectile_speed: 500.0,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
Dagger(_) => vec![
|
Dagger(_) => vec![BasicMelee {
|
||||||
BasicMelee {
|
energy_cost: 0,
|
||||||
energy_cost: 0,
|
buildup_duration: Duration::from_millis(100),
|
||||||
buildup_duration: Duration::from_millis(100),
|
recover_duration: Duration::from_millis(400),
|
||||||
recover_duration: Duration::from_millis(400),
|
base_healthchange: (-50.0 * self.base_power()) as i32,
|
||||||
base_healthchange: (-50.0 * self.base_power()) as i32,
|
range: 3.5,
|
||||||
knockback: 0.0,
|
max_angle: 20.0,
|
||||||
range: 3.5,
|
}],
|
||||||
max_angle: 20.0,
|
|
||||||
},
|
|
||||||
DashMelee {
|
|
||||||
energy_cost: 700,
|
|
||||||
buildup_duration: Duration::from_millis(500),
|
|
||||||
recover_duration: Duration::from_millis(500),
|
|
||||||
base_damage: (100.0 * self.base_power()) as u32,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
Staff(kind) => {
|
Staff(kind) => {
|
||||||
if kind == "Sceptre" {
|
if kind == "Sceptre" {
|
||||||
vec![
|
vec![
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
comp::{Attacking, CharacterState, EnergySource, StateUpdate},
|
comp::{Attacking, CharacterState, EnergySource, StateUpdate},
|
||||||
states::{utils::*, wielding::StageSection},
|
states::utils::{StageSection, *},
|
||||||
sys::character_behavior::{CharacterBehavior, JoinData},
|
sys::character_behavior::{CharacterBehavior, JoinData},
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@ -109,8 +109,13 @@ impl CharacterBehavior for Data {
|
|||||||
&& self.timer < self.stage_data[stage_index].base_swing_duration
|
&& self.timer < self.stage_data[stage_index].base_swing_duration
|
||||||
{
|
{
|
||||||
// Forward movement
|
// Forward movement
|
||||||
forward_move(data, &mut update, 0.1, self.stage_data[stage_index].forward_movement * 3.0);
|
forward_move(
|
||||||
|
data,
|
||||||
|
&mut update,
|
||||||
|
0.1,
|
||||||
|
self.stage_data[stage_index].forward_movement,
|
||||||
|
);
|
||||||
|
|
||||||
// Swings
|
// Swings
|
||||||
update.character = CharacterState::ComboMelee(Data {
|
update.character = CharacterState::ComboMelee(Data {
|
||||||
stage: self.stage,
|
stage: self.stage,
|
||||||
@ -197,54 +202,7 @@ impl CharacterBehavior for Data {
|
|||||||
next_stage: self.next_stage,
|
next_stage: self.next_stage,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} /*else if self.stage_section == StageSection::Recover {
|
} else if self.next_stage {
|
||||||
update.character = CharacterState::ComboMelee(Data {
|
|
||||||
stage: self.stage,
|
|
||||||
num_stages: self.num_stages,
|
|
||||||
combo: self.combo,
|
|
||||||
stage_data: self.stage_data.clone(),
|
|
||||||
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::Combo,
|
|
||||||
next_stage: self.next_stage,
|
|
||||||
});
|
|
||||||
} else if self.stage_section == StageSection::Combo && self.timer < self.combo_duration {
|
|
||||||
if data.inputs.primary.is_pressed() {
|
|
||||||
update.character = CharacterState::ComboMelee(Data {
|
|
||||||
stage: (self.stage % self.num_stages) + 1,
|
|
||||||
num_stages: self.num_stages,
|
|
||||||
combo: self.combo + 1,
|
|
||||||
stage_data: self.stage_data.clone(),
|
|
||||||
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: self.next_stage,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
update.character = CharacterState::ComboMelee(Data {
|
|
||||||
stage: self.stage,
|
|
||||||
num_stages: self.num_stages,
|
|
||||||
combo: self.combo,
|
|
||||||
stage_data: self.stage_data.clone(),
|
|
||||||
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))
|
|
||||||
.unwrap_or_default(),
|
|
||||||
stage_section: self.stage_section,
|
|
||||||
next_stage: self.next_stage,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}*/ else if self.next_stage {
|
|
||||||
// Transitions to buildup section of next stage
|
// Transitions to buildup section of next stage
|
||||||
update.character = CharacterState::ComboMelee(Data {
|
update.character = CharacterState::ComboMelee(Data {
|
||||||
stage: (self.stage % self.num_stages) + 1,
|
stage: (self.stage % self.num_stages) + 1,
|
||||||
@ -258,7 +216,7 @@ impl CharacterBehavior for Data {
|
|||||||
timer: Duration::default(),
|
timer: Duration::default(),
|
||||||
stage_section: StageSection::Buildup,
|
stage_section: StageSection::Buildup,
|
||||||
next_stage: false,
|
next_stage: false,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Done
|
// Done
|
||||||
update.character = CharacterState::Wielding;
|
update.character = CharacterState::Wielding;
|
||||||
|
@ -1,88 +1,242 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
comp::{Attacking, CharacterState, StateUpdate},
|
comp::{Attacking, CharacterState, EnergySource, StateUpdate},
|
||||||
states::utils::*,
|
states::utils::{StageSection, *},
|
||||||
sys::character_behavior::*,
|
sys::character_behavior::*,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use vek::Vec3;
|
|
||||||
|
|
||||||
const DASH_SPEED: f32 = 19.0;
|
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
|
||||||
pub struct Data {
|
pub struct Data {
|
||||||
|
/// How much damage the attack initially does
|
||||||
|
pub base_damage: u32,
|
||||||
|
/// How much damage the attack does at max charge distance
|
||||||
|
pub max_damage: u32,
|
||||||
|
/// How much the attack knocks the target back initially
|
||||||
|
pub base_knockback: f32,
|
||||||
|
/// How much knockback happens at max charge distance
|
||||||
|
pub max_knockback: f32,
|
||||||
|
/// Range of the attack
|
||||||
|
pub range: f32,
|
||||||
|
/// Angle of the attack
|
||||||
|
pub angle: f32,
|
||||||
|
/// Rate of energy drain
|
||||||
|
pub energy_drain: u32,
|
||||||
|
/// How quickly dasher moves forward
|
||||||
|
pub forward_speed: f32,
|
||||||
/// How long until state should deal damage
|
/// How long until state should deal damage
|
||||||
pub buildup_duration: Duration,
|
pub buildup_duration: Duration,
|
||||||
|
/// How long the state charges for until it reaches max damage
|
||||||
|
pub charge_duration: Duration,
|
||||||
|
/// How high timer got while in charge potion
|
||||||
|
pub charge_duration_attained: Duration,
|
||||||
|
/// Whether state keeps charging after reaching max charge duration
|
||||||
|
pub infinite_charge: bool,
|
||||||
|
/// How long the state swings for
|
||||||
|
pub swing_duration: Duration,
|
||||||
/// How long the state has until exiting
|
/// How long the state has until exiting
|
||||||
pub recover_duration: Duration,
|
pub recover_duration: Duration,
|
||||||
/// Base damage
|
/// Timer for each stage
|
||||||
pub base_damage: u32,
|
pub timer: Duration,
|
||||||
/// Whether the attack can deal more damage
|
/// What section the character stage is in
|
||||||
pub exhausted: bool,
|
pub stage_section: StageSection,
|
||||||
pub initialize: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CharacterBehavior for Data {
|
impl CharacterBehavior for Data {
|
||||||
fn behavior(&self, data: &JoinData) -> StateUpdate {
|
fn behavior(&self, data: &JoinData) -> StateUpdate {
|
||||||
let mut update = StateUpdate::from(data);
|
let mut update = StateUpdate::from(data);
|
||||||
|
|
||||||
if self.initialize {
|
handle_orientation(data, &mut update, 1.0);
|
||||||
update.vel.0 = *data.inputs.look_dir * 20.0;
|
handle_move(data, &mut update, 0.1);
|
||||||
if let Some(dir) = Vec3::from(data.inputs.look_dir.xy()).try_normalized() {
|
|
||||||
update.ori.0 = dir.into();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.buildup_duration != Duration::default() && data.physics.touch_entities.is_empty() {
|
|
||||||
// Build up (this will move you forward)
|
|
||||||
update.vel.0 = Vec3::new(0.0, 0.0, update.vel.0.z)
|
|
||||||
+ (update.vel.0 * Vec3::new(1.0, 1.0, 0.0)
|
|
||||||
+ 1.5 * data.inputs.move_dir.try_normalized().unwrap_or_default())
|
|
||||||
.try_normalized()
|
|
||||||
.unwrap_or_default()
|
|
||||||
* DASH_SPEED;
|
|
||||||
|
|
||||||
|
if self.stage_section == StageSection::Buildup && self.timer < self.buildup_duration {
|
||||||
|
// Build up
|
||||||
update.character = CharacterState::DashMelee(Data {
|
update.character = CharacterState::DashMelee(Data {
|
||||||
buildup_duration: self
|
|
||||||
.buildup_duration
|
|
||||||
.checked_sub(Duration::from_secs_f32(data.dt.0))
|
|
||||||
.unwrap_or_default(),
|
|
||||||
recover_duration: self.recover_duration,
|
|
||||||
base_damage: self.base_damage,
|
base_damage: self.base_damage,
|
||||||
exhausted: false,
|
max_damage: self.max_damage,
|
||||||
initialize: false,
|
base_knockback: self.base_knockback,
|
||||||
|
max_knockback: self.max_knockback,
|
||||||
|
range: self.range,
|
||||||
|
angle: self.angle,
|
||||||
|
energy_drain: self.energy_drain,
|
||||||
|
forward_speed: self.forward_speed,
|
||||||
|
buildup_duration: self.buildup_duration,
|
||||||
|
charge_duration: self.charge_duration,
|
||||||
|
charge_duration_attained: self.charge_duration_attained,
|
||||||
|
infinite_charge: self.infinite_charge,
|
||||||
|
swing_duration: self.swing_duration,
|
||||||
|
recover_duration: self.recover_duration,
|
||||||
|
timer: self
|
||||||
|
.timer
|
||||||
|
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||||
|
.unwrap_or_default(),
|
||||||
|
stage_section: self.stage_section,
|
||||||
|
})
|
||||||
|
} else if self.stage_section == StageSection::Buildup {
|
||||||
|
// Transitions to charge section of stage
|
||||||
|
update.character = CharacterState::DashMelee(Data {
|
||||||
|
base_damage: self.base_damage,
|
||||||
|
max_damage: self.max_damage,
|
||||||
|
base_knockback: self.base_knockback,
|
||||||
|
max_knockback: self.max_knockback,
|
||||||
|
range: self.range,
|
||||||
|
angle: self.angle,
|
||||||
|
energy_drain: self.energy_drain,
|
||||||
|
forward_speed: self.forward_speed,
|
||||||
|
buildup_duration: self.buildup_duration,
|
||||||
|
charge_duration: self.charge_duration,
|
||||||
|
charge_duration_attained: self.charge_duration_attained,
|
||||||
|
infinite_charge: self.infinite_charge,
|
||||||
|
swing_duration: self.swing_duration,
|
||||||
|
recover_duration: self.recover_duration,
|
||||||
|
timer: Duration::default(),
|
||||||
|
stage_section: StageSection::Charge,
|
||||||
|
})
|
||||||
|
} else if self.stage_section == StageSection::Charge /*&& data.physics.touch_entities.is_empty()*/ && ((self.timer < self.charge_duration && !self.infinite_charge) || (data.inputs.secondary.is_pressed() && self.infinite_charge)) && update.energy.current() > 0
|
||||||
|
{
|
||||||
|
// Forward movement
|
||||||
|
forward_move(data, &mut update, 0.1, self.forward_speed);
|
||||||
|
|
||||||
|
// Charges
|
||||||
|
update.character = CharacterState::DashMelee(Data {
|
||||||
|
base_damage: self.base_damage,
|
||||||
|
max_damage: self.max_damage,
|
||||||
|
base_knockback: self.base_knockback,
|
||||||
|
max_knockback: self.max_knockback,
|
||||||
|
range: self.range,
|
||||||
|
angle: self.angle,
|
||||||
|
energy_drain: self.energy_drain,
|
||||||
|
forward_speed: self.forward_speed,
|
||||||
|
buildup_duration: self.buildup_duration,
|
||||||
|
charge_duration: self.charge_duration,
|
||||||
|
charge_duration_attained: self.charge_duration_attained,
|
||||||
|
infinite_charge: self.infinite_charge,
|
||||||
|
swing_duration: self.swing_duration,
|
||||||
|
recover_duration: self.recover_duration,
|
||||||
|
timer: self
|
||||||
|
.timer
|
||||||
|
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||||
|
.unwrap_or_default(),
|
||||||
|
stage_section: self.stage_section,
|
||||||
});
|
});
|
||||||
} else if !self.exhausted {
|
|
||||||
|
// Consumes energy if there's enough left and charge has not stopped
|
||||||
|
update.energy.change_by(
|
||||||
|
-(self.energy_drain as f32 * data.dt.0) as i32,
|
||||||
|
EnergySource::Ability,
|
||||||
|
);
|
||||||
|
} else if self.stage_section == StageSection::Charge {
|
||||||
|
// Transitions to swing section of stage
|
||||||
|
update.character = CharacterState::DashMelee(Data {
|
||||||
|
base_damage: self.base_damage,
|
||||||
|
max_damage: self.max_damage,
|
||||||
|
base_knockback: self.base_knockback,
|
||||||
|
max_knockback: self.max_knockback,
|
||||||
|
range: self.range,
|
||||||
|
angle: self.angle,
|
||||||
|
energy_drain: self.energy_drain,
|
||||||
|
forward_speed: self.forward_speed,
|
||||||
|
buildup_duration: self.buildup_duration,
|
||||||
|
charge_duration: self.charge_duration,
|
||||||
|
charge_duration_attained: self.charge_duration_attained,
|
||||||
|
infinite_charge: self.infinite_charge,
|
||||||
|
swing_duration: self.swing_duration,
|
||||||
|
recover_duration: self.recover_duration,
|
||||||
|
timer: Duration::default(),
|
||||||
|
stage_section: StageSection::Swing,
|
||||||
|
})
|
||||||
|
} else if self.stage_section == StageSection::Swing && self.timer < self.swing_duration {
|
||||||
|
// Swings
|
||||||
|
let charge_attained = if self.timer > self.charge_duration_attained {
|
||||||
|
if self.timer > self.charge_duration_attained {
|
||||||
|
self.charge_duration
|
||||||
|
} else {
|
||||||
|
self.timer
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self.charge_duration_attained
|
||||||
|
};
|
||||||
|
update.character = CharacterState::DashMelee(Data {
|
||||||
|
base_damage: self.base_damage,
|
||||||
|
max_damage: self.max_damage,
|
||||||
|
base_knockback: self.base_knockback,
|
||||||
|
max_knockback: self.max_knockback,
|
||||||
|
range: self.range,
|
||||||
|
angle: self.angle,
|
||||||
|
energy_drain: self.energy_drain,
|
||||||
|
forward_speed: self.forward_speed,
|
||||||
|
buildup_duration: self.buildup_duration,
|
||||||
|
charge_duration: self.charge_duration,
|
||||||
|
charge_duration_attained: charge_attained,
|
||||||
|
infinite_charge: self.infinite_charge,
|
||||||
|
swing_duration: self.swing_duration,
|
||||||
|
recover_duration: self.recover_duration,
|
||||||
|
timer: self
|
||||||
|
.timer
|
||||||
|
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||||
|
.unwrap_or_default(),
|
||||||
|
stage_section: self.stage_section,
|
||||||
|
})
|
||||||
|
} else if self.stage_section == StageSection::Swing {
|
||||||
// Hit attempt
|
// Hit attempt
|
||||||
|
let charge_frac =
|
||||||
|
(self.charge_duration_attained.as_secs_f32() / self.charge_duration.as_secs_f32()).min(1.0);
|
||||||
|
let damage = (self.max_damage as f32 - self.base_damage as f32) * charge_frac
|
||||||
|
+ self.base_damage as f32;
|
||||||
|
let knockback =
|
||||||
|
(self.max_knockback - self.base_knockback) * charge_frac + self.base_knockback;
|
||||||
data.updater.insert(data.entity, Attacking {
|
data.updater.insert(data.entity, Attacking {
|
||||||
base_healthchange: -(self.base_damage as i32),
|
base_healthchange: -damage as i32,
|
||||||
range: 3.5,
|
range: self.range,
|
||||||
max_angle: 45_f32.to_radians(),
|
max_angle: self.angle.to_radians(),
|
||||||
applied: false,
|
applied: false,
|
||||||
hit_count: 0,
|
hit_count: 0,
|
||||||
knockback: 0.0,
|
knockback,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Transitions to recover section of stage
|
||||||
update.character = CharacterState::DashMelee(Data {
|
update.character = CharacterState::DashMelee(Data {
|
||||||
buildup_duration: Duration::default(),
|
|
||||||
recover_duration: self.recover_duration,
|
|
||||||
base_damage: self.base_damage,
|
base_damage: self.base_damage,
|
||||||
exhausted: true,
|
max_damage: self.max_damage,
|
||||||
initialize: false,
|
base_knockback: self.base_knockback,
|
||||||
});
|
max_knockback: self.max_knockback,
|
||||||
} else if self.recover_duration != Duration::default() {
|
range: self.range,
|
||||||
// Recovery
|
angle: self.angle,
|
||||||
handle_move(data, &mut update, 0.7);
|
energy_drain: self.energy_drain,
|
||||||
update.character = CharacterState::DashMelee(Data {
|
forward_speed: self.forward_speed,
|
||||||
buildup_duration: self.buildup_duration,
|
buildup_duration: self.buildup_duration,
|
||||||
recover_duration: self
|
charge_duration: self.charge_duration,
|
||||||
.recover_duration
|
charge_duration_attained: self.charge_duration_attained,
|
||||||
.checked_sub(Duration::from_secs_f32(data.dt.0))
|
infinite_charge: self.infinite_charge,
|
||||||
.unwrap_or_default(),
|
swing_duration: self.swing_duration,
|
||||||
|
recover_duration: self.recover_duration,
|
||||||
|
timer: Duration::default(),
|
||||||
|
stage_section: StageSection::Recover,
|
||||||
|
})
|
||||||
|
} else if self.stage_section == StageSection::Recover && self.timer < self.recover_duration
|
||||||
|
{
|
||||||
|
// Recover
|
||||||
|
update.character = CharacterState::DashMelee(Data {
|
||||||
base_damage: self.base_damage,
|
base_damage: self.base_damage,
|
||||||
exhausted: true,
|
max_damage: self.max_damage,
|
||||||
initialize: false,
|
base_knockback: self.base_knockback,
|
||||||
});
|
max_knockback: self.max_knockback,
|
||||||
|
range: self.range,
|
||||||
|
angle: self.angle,
|
||||||
|
energy_drain: self.energy_drain,
|
||||||
|
forward_speed: self.forward_speed,
|
||||||
|
buildup_duration: self.buildup_duration,
|
||||||
|
charge_duration: self.charge_duration,
|
||||||
|
charge_duration_attained: self.charge_duration_attained,
|
||||||
|
infinite_charge: self.infinite_charge,
|
||||||
|
swing_duration: self.swing_duration,
|
||||||
|
recover_duration: self.recover_duration,
|
||||||
|
timer: self
|
||||||
|
.timer
|
||||||
|
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||||
|
.unwrap_or_default(),
|
||||||
|
stage_section: self.stage_section,
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
// Done
|
// Done
|
||||||
update.character = CharacterState::Wielding;
|
update.character = CharacterState::Wielding;
|
||||||
|
@ -8,6 +8,7 @@ use crate::{
|
|||||||
sys::{character_behavior::JoinData, phys::GRAVITY},
|
sys::{character_behavior::JoinData, phys::GRAVITY},
|
||||||
util::Dir,
|
util::Dir,
|
||||||
};
|
};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
pub const MOVEMENT_THRESHOLD_VEL: f32 = 3.0;
|
pub const MOVEMENT_THRESHOLD_VEL: f32 = 3.0;
|
||||||
@ -97,10 +98,12 @@ pub fn forward_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32,
|
|||||||
BASE_HUMANOID_AIR_ACCEL
|
BASE_HUMANOID_AIR_ACCEL
|
||||||
};
|
};
|
||||||
|
|
||||||
update.vel.0 =
|
update.vel.0 = update.vel.0
|
||||||
update.vel.0 + Vec2::broadcast(data.dt.0) * data.inputs.move_dir * accel * efficiency + (*update.ori.0).xy() * forward;
|
+ Vec2::broadcast(data.dt.0)
|
||||||
|
* accel
|
||||||
|
* (data.inputs.move_dir * efficiency + (*update.ori.0).xy() * forward);
|
||||||
|
|
||||||
handle_orientation(data, update, data.body.base_ori_rate());
|
handle_orientation(data, update, data.body.base_ori_rate() * efficiency);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_orientation(data: &JoinData, update: &mut StateUpdate, rate: f32) {
|
pub fn handle_orientation(data: &JoinData, update: &mut StateUpdate, rate: f32) {
|
||||||
@ -344,3 +347,14 @@ pub fn unwrap_tool_data<'a>(data: &'a JoinData) -> Option<&'a Tool> {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Determines what portion a state is in. Used in all attacks (eventually). Is
|
||||||
|
/// used to control aspects of animation code, as well as logic within the
|
||||||
|
/// character states.
|
||||||
|
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
||||||
|
pub enum StageSection {
|
||||||
|
Buildup,
|
||||||
|
Swing,
|
||||||
|
Recover,
|
||||||
|
Charge,
|
||||||
|
}
|
||||||
|
@ -3,7 +3,6 @@ use crate::{
|
|||||||
comp::{CharacterState, StateUpdate},
|
comp::{CharacterState, StateUpdate},
|
||||||
sys::character_behavior::{CharacterBehavior, JoinData},
|
sys::character_behavior::{CharacterBehavior, JoinData},
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
pub struct Data;
|
pub struct Data;
|
||||||
|
|
||||||
@ -58,14 +57,3 @@ impl CharacterBehavior for Data {
|
|||||||
update
|
update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Determines what portion a state is in. Used in all attacks (eventually). Is
|
|
||||||
/// used to control aspects of animation code, as well as logic within the
|
|
||||||
/// character states.
|
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
|
||||||
pub enum StageSection {
|
|
||||||
Buildup,
|
|
||||||
Swing,
|
|
||||||
Recover,
|
|
||||||
Combo,
|
|
||||||
}
|
|
||||||
|
@ -4,7 +4,7 @@ use super::{
|
|||||||
};
|
};
|
||||||
use common::{
|
use common::{
|
||||||
comp::item::{Hands, ToolKind},
|
comp::item::{Hands, ToolKind},
|
||||||
states::wielding::StageSection,
|
states::utils::StageSection,
|
||||||
};
|
};
|
||||||
use std::f32::consts::PI;
|
use std::f32::consts::PI;
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ impl Animation for AlphaAnimation {
|
|||||||
// next.torso.orientation = Quaternion::rotation_z(test2
|
// next.torso.orientation = Quaternion::rotation_z(test2
|
||||||
// * 7.2);
|
// * 7.2);
|
||||||
},
|
},
|
||||||
StageSection::Recover | StageSection::Combo => {
|
StageSection::Recover => {
|
||||||
//println!("{:.3} recover", anim_time);
|
//println!("{:.3} recover", anim_time);
|
||||||
next.control.position = Vec3::new(-7.0, 7.0, 2.0);
|
next.control.position = Vec3::new(-7.0, 7.0, 2.0);
|
||||||
next.control.orientation = Quaternion::rotation_x(0.0)
|
next.control.orientation = Quaternion::rotation_x(0.0)
|
||||||
@ -131,6 +131,7 @@ impl Animation for AlphaAnimation {
|
|||||||
next.head.orientation =
|
next.head.orientation =
|
||||||
Quaternion::rotation_y(0.0) * Quaternion::rotation_z(1.57);
|
Quaternion::rotation_y(0.0) * Quaternion::rotation_z(1.57);
|
||||||
},
|
},
|
||||||
|
_ => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ use super::{
|
|||||||
};
|
};
|
||||||
use common::{
|
use common::{
|
||||||
comp::item::{Hands, ToolKind},
|
comp::item::{Hands, ToolKind},
|
||||||
states::wielding::StageSection,
|
states::utils::StageSection,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct BetaAnimation;
|
pub struct BetaAnimation;
|
||||||
@ -98,7 +98,7 @@ impl Animation for BetaAnimation {
|
|||||||
next.head.orientation = Quaternion::rotation_y(0.1)
|
next.head.orientation = Quaternion::rotation_y(0.1)
|
||||||
* Quaternion::rotation_z(-1.2 + test * -0.5);
|
* Quaternion::rotation_z(-1.2 + test * -0.5);
|
||||||
},
|
},
|
||||||
StageSection::Recover | StageSection::Combo => {
|
StageSection::Recover => {
|
||||||
next.control.position = Vec3::new(10.0 + movement * -5.0, 8.0, 6.0);
|
next.control.position = Vec3::new(10.0 + movement * -5.0, 8.0, 6.0);
|
||||||
next.control.orientation = Quaternion::rotation_x(-1.57)
|
next.control.orientation = Quaternion::rotation_x(-1.57)
|
||||||
* Quaternion::rotation_y(2.0)
|
* Quaternion::rotation_y(2.0)
|
||||||
@ -108,6 +108,7 @@ impl Animation for BetaAnimation {
|
|||||||
next.head.orientation =
|
next.head.orientation =
|
||||||
Quaternion::rotation_y(0.1) * Quaternion::rotation_z(-1.5);
|
Quaternion::rotation_y(0.1) * Quaternion::rotation_z(-1.5);
|
||||||
},
|
},
|
||||||
|
_ => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ use super::{
|
|||||||
};
|
};
|
||||||
use common::{
|
use common::{
|
||||||
comp::item::{Hands, ToolKind},
|
comp::item::{Hands, ToolKind},
|
||||||
states::wielding::StageSection,
|
states::utils::StageSection,
|
||||||
};
|
};
|
||||||
use std::f32::consts::PI;
|
use std::f32::consts::PI;
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ impl Animation for SpinAnimation {
|
|||||||
next.shorts.orientation = Quaternion::rotation_z(test2 * 1.5);
|
next.shorts.orientation = Quaternion::rotation_z(test2 * 1.5);
|
||||||
next.torso.orientation = Quaternion::rotation_z(test2 * 7.2);
|
next.torso.orientation = Quaternion::rotation_z(test2 * 7.2);
|
||||||
},
|
},
|
||||||
StageSection::Recover | StageSection::Combo => {
|
StageSection::Recover => {
|
||||||
//println!("{:.3} recover", anim_time);
|
//println!("{:.3} recover", anim_time);
|
||||||
next.control.position = Vec3::new(
|
next.control.position = Vec3::new(
|
||||||
-8.0,
|
-8.0,
|
||||||
@ -119,6 +119,7 @@ impl Animation for SpinAnimation {
|
|||||||
next.head.orientation = Quaternion::rotation_y(movement * 0.1)
|
next.head.orientation = Quaternion::rotation_y(movement * 0.1)
|
||||||
* Quaternion::rotation_z(movement * -0.1);
|
* Quaternion::rotation_z(movement * -0.1);
|
||||||
},
|
},
|
||||||
|
_ => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ use common::{
|
|||||||
},
|
},
|
||||||
span,
|
span,
|
||||||
state::{DeltaTime, State},
|
state::{DeltaTime, State},
|
||||||
states::wielding::StageSection,
|
states::utils::StageSection,
|
||||||
terrain::TerrainChunk,
|
terrain::TerrainChunk,
|
||||||
vol::RectRasterableVol,
|
vol::RectRasterableVol,
|
||||||
};
|
};
|
||||||
@ -946,7 +946,7 @@ impl FigureMgr {
|
|||||||
.base_recover_duration
|
.base_recover_duration
|
||||||
.as_secs_f64()
|
.as_secs_f64()
|
||||||
},
|
},
|
||||||
StageSection::Combo => stage_time / s.combo_duration.as_secs_f64(),
|
_ => 0.0,
|
||||||
};
|
};
|
||||||
match s.stage {
|
match s.stage {
|
||||||
1 => anim::character::AlphaAnimation::update_skeleton(
|
1 => anim::character::AlphaAnimation::update_skeleton(
|
||||||
|
Loading…
Reference in New Issue
Block a user