mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Addressed comments
This commit is contained in:
@ -381,19 +381,21 @@ impl From<&CharacterAbility> for CharacterState {
|
|||||||
max_speed_increase,
|
max_speed_increase,
|
||||||
is_interruptible,
|
is_interruptible,
|
||||||
} => CharacterState::ComboMelee(combo_melee::Data {
|
} => CharacterState::ComboMelee(combo_melee::Data {
|
||||||
|
static_data: combo_melee::StaticData {
|
||||||
|
num_stages: stage_data.len() as u32,
|
||||||
|
stage_data: stage_data.clone(),
|
||||||
|
initial_energy_gain: *initial_energy_gain,
|
||||||
|
max_energy_gain: *max_energy_gain,
|
||||||
|
energy_increase: *energy_increase,
|
||||||
|
speed_increase: 1.0 - *speed_increase,
|
||||||
|
max_speed_increase: *max_speed_increase - 1.0,
|
||||||
|
is_interruptible: *is_interruptible,
|
||||||
|
},
|
||||||
stage: 1,
|
stage: 1,
|
||||||
num_stages: stage_data.len() as u32,
|
|
||||||
combo: 0,
|
combo: 0,
|
||||||
stage_data: stage_data.clone(),
|
|
||||||
initial_energy_gain: *initial_energy_gain,
|
|
||||||
max_energy_gain: *max_energy_gain,
|
|
||||||
energy_increase: *energy_increase,
|
|
||||||
timer: Duration::default(),
|
timer: Duration::default(),
|
||||||
stage_section: StageSection::Buildup,
|
stage_section: StageSection::Buildup,
|
||||||
next_stage: false,
|
next_stage: false,
|
||||||
speed_increase: 1.0 - *speed_increase,
|
|
||||||
max_speed_increase: *max_speed_increase - 1.0,
|
|
||||||
is_interruptible: *is_interruptible,
|
|
||||||
}),
|
}),
|
||||||
CharacterAbility::LeapMelee {
|
CharacterAbility::LeapMelee {
|
||||||
energy_cost: _,
|
energy_cost: _,
|
||||||
|
@ -124,67 +124,28 @@ impl LoadoutBuilder {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let loadout = match body {
|
let loadout = match body {
|
||||||
Body::Humanoid(_) => match is_giant {
|
Body::Humanoid(_) => {
|
||||||
true => Loadout {
|
if is_giant {
|
||||||
active_item,
|
Loadout {
|
||||||
second_item: None,
|
|
||||||
shoulder: Some(Item::new_from_asset_expect(
|
|
||||||
"common.items.armor.shoulder.plate_0",
|
|
||||||
)),
|
|
||||||
chest: Some(Item::new_from_asset_expect(
|
|
||||||
"common.items.armor.chest.plate_green_0",
|
|
||||||
)),
|
|
||||||
belt: Some(Item::new_from_asset_expect(
|
|
||||||
"common.items.armor.belt.plate_0",
|
|
||||||
)),
|
|
||||||
hand: Some(Item::new_from_asset_expect(
|
|
||||||
"common.items.armor.hand.plate_0",
|
|
||||||
)),
|
|
||||||
pants: Some(Item::new_from_asset_expect(
|
|
||||||
"common.items.armor.pants.plate_green_0",
|
|
||||||
)),
|
|
||||||
foot: Some(Item::new_from_asset_expect(
|
|
||||||
"common.items.armor.foot.plate_0",
|
|
||||||
)),
|
|
||||||
back: None,
|
|
||||||
ring: None,
|
|
||||||
neck: None,
|
|
||||||
lantern: None,
|
|
||||||
glider: None,
|
|
||||||
head: None,
|
|
||||||
tabard: None,
|
|
||||||
},
|
|
||||||
false => match alignment {
|
|
||||||
Alignment::Npc => Loadout {
|
|
||||||
active_item,
|
active_item,
|
||||||
second_item: None,
|
second_item: None,
|
||||||
shoulder: None,
|
shoulder: Some(Item::new_from_asset_expect(
|
||||||
|
"common.items.armor.shoulder.plate_0",
|
||||||
|
)),
|
||||||
chest: Some(Item::new_from_asset_expect(
|
chest: Some(Item::new_from_asset_expect(
|
||||||
match rand::thread_rng().gen_range(0, 10) {
|
"common.items.armor.chest.plate_green_0",
|
||||||
0 => "common.items.armor.chest.worker_green_0",
|
|
||||||
1 => "common.items.armor.chest.worker_green_1",
|
|
||||||
2 => "common.items.armor.chest.worker_red_0",
|
|
||||||
3 => "common.items.armor.chest.worker_red_1",
|
|
||||||
4 => "common.items.armor.chest.worker_purple_0",
|
|
||||||
5 => "common.items.armor.chest.worker_purple_1",
|
|
||||||
6 => "common.items.armor.chest.worker_yellow_0",
|
|
||||||
7 => "common.items.armor.chest.worker_yellow_1",
|
|
||||||
8 => "common.items.armor.chest.worker_orange_0",
|
|
||||||
_ => "common.items.armor.chest.worker_orange_1",
|
|
||||||
},
|
|
||||||
)),
|
)),
|
||||||
belt: Some(Item::new_from_asset_expect(
|
belt: Some(Item::new_from_asset_expect(
|
||||||
"common.items.armor.belt.leather_0",
|
"common.items.armor.belt.plate_0",
|
||||||
|
)),
|
||||||
|
hand: Some(Item::new_from_asset_expect(
|
||||||
|
"common.items.armor.hand.plate_0",
|
||||||
)),
|
)),
|
||||||
hand: None,
|
|
||||||
pants: Some(Item::new_from_asset_expect(
|
pants: Some(Item::new_from_asset_expect(
|
||||||
"common.items.armor.pants.worker_blue_0",
|
"common.items.armor.pants.plate_green_0",
|
||||||
)),
|
)),
|
||||||
foot: Some(Item::new_from_asset_expect(
|
foot: Some(Item::new_from_asset_expect(
|
||||||
match rand::thread_rng().gen_range(0, 2) {
|
"common.items.armor.foot.plate_0",
|
||||||
0 => "common.items.armor.foot.leather_0",
|
|
||||||
_ => "common.items.armor.starter.sandals_0",
|
|
||||||
},
|
|
||||||
)),
|
)),
|
||||||
back: None,
|
back: None,
|
||||||
ring: None,
|
ring: None,
|
||||||
@ -193,40 +154,84 @@ impl LoadoutBuilder {
|
|||||||
glider: None,
|
glider: None,
|
||||||
head: None,
|
head: None,
|
||||||
tabard: None,
|
tabard: None,
|
||||||
},
|
}
|
||||||
Alignment::Enemy => Loadout {
|
} else {
|
||||||
active_item,
|
match alignment {
|
||||||
second_item: None,
|
Alignment::Npc => Loadout {
|
||||||
shoulder: Some(Item::new_from_asset_expect(
|
active_item,
|
||||||
"common.items.armor.shoulder.cultist_shoulder_purple",
|
second_item: None,
|
||||||
)),
|
shoulder: None,
|
||||||
chest: Some(Item::new_from_asset_expect(
|
chest: Some(Item::new_from_asset_expect(
|
||||||
"common.items.armor.chest.cultist_chest_purple",
|
match rand::thread_rng().gen_range(0, 10) {
|
||||||
)),
|
0 => "common.items.armor.chest.worker_green_0",
|
||||||
belt: Some(Item::new_from_asset_expect(
|
1 => "common.items.armor.chest.worker_green_1",
|
||||||
"common.items.armor.belt.cultist_belt",
|
2 => "common.items.armor.chest.worker_red_0",
|
||||||
)),
|
3 => "common.items.armor.chest.worker_red_1",
|
||||||
hand: Some(Item::new_from_asset_expect(
|
4 => "common.items.armor.chest.worker_purple_0",
|
||||||
"common.items.armor.hand.cultist_hands_purple",
|
5 => "common.items.armor.chest.worker_purple_1",
|
||||||
)),
|
6 => "common.items.armor.chest.worker_yellow_0",
|
||||||
pants: Some(Item::new_from_asset_expect(
|
7 => "common.items.armor.chest.worker_yellow_1",
|
||||||
"common.items.armor.pants.cultist_legs_purple",
|
8 => "common.items.armor.chest.worker_orange_0",
|
||||||
)),
|
_ => "common.items.armor.chest.worker_orange_1",
|
||||||
foot: Some(Item::new_from_asset_expect(
|
},
|
||||||
"common.items.armor.foot.cultist_boots",
|
)),
|
||||||
)),
|
belt: Some(Item::new_from_asset_expect(
|
||||||
back: Some(Item::new_from_asset_expect(
|
"common.items.armor.belt.leather_0",
|
||||||
"common.items.armor.back.dungeon_purple-0",
|
)),
|
||||||
)),
|
hand: None,
|
||||||
ring: None,
|
pants: Some(Item::new_from_asset_expect(
|
||||||
neck: None,
|
"common.items.armor.pants.worker_blue_0",
|
||||||
lantern: Some(Item::new_from_asset_expect("common.items.lantern.black_0")),
|
)),
|
||||||
glider: None,
|
foot: Some(Item::new_from_asset_expect(
|
||||||
head: None,
|
match rand::thread_rng().gen_range(0, 2) {
|
||||||
tabard: None,
|
0 => "common.items.armor.foot.leather_0",
|
||||||
},
|
_ => "common.items.armor.starter.sandals_0",
|
||||||
_ => LoadoutBuilder::animal(body).build(),
|
},
|
||||||
},
|
)),
|
||||||
|
back: None,
|
||||||
|
ring: None,
|
||||||
|
neck: None,
|
||||||
|
lantern: None,
|
||||||
|
glider: None,
|
||||||
|
head: None,
|
||||||
|
tabard: None,
|
||||||
|
},
|
||||||
|
Alignment::Enemy => Loadout {
|
||||||
|
active_item,
|
||||||
|
second_item: None,
|
||||||
|
shoulder: Some(Item::new_from_asset_expect(
|
||||||
|
"common.items.armor.shoulder.cultist_shoulder_purple",
|
||||||
|
)),
|
||||||
|
chest: Some(Item::new_from_asset_expect(
|
||||||
|
"common.items.armor.chest.cultist_chest_purple",
|
||||||
|
)),
|
||||||
|
belt: Some(Item::new_from_asset_expect(
|
||||||
|
"common.items.armor.belt.cultist_belt",
|
||||||
|
)),
|
||||||
|
hand: Some(Item::new_from_asset_expect(
|
||||||
|
"common.items.armor.hand.cultist_hands_purple",
|
||||||
|
)),
|
||||||
|
pants: Some(Item::new_from_asset_expect(
|
||||||
|
"common.items.armor.pants.cultist_legs_purple",
|
||||||
|
)),
|
||||||
|
foot: Some(Item::new_from_asset_expect(
|
||||||
|
"common.items.armor.foot.cultist_boots",
|
||||||
|
)),
|
||||||
|
back: Some(Item::new_from_asset_expect(
|
||||||
|
"common.items.armor.back.dungeon_purple-0",
|
||||||
|
)),
|
||||||
|
ring: None,
|
||||||
|
neck: None,
|
||||||
|
lantern: Some(Item::new_from_asset_expect(
|
||||||
|
"common.items.lantern.black_0",
|
||||||
|
)),
|
||||||
|
glider: None,
|
||||||
|
head: None,
|
||||||
|
tabard: None,
|
||||||
|
},
|
||||||
|
_ => LoadoutBuilder::animal(body).build(),
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
Body::Golem(golem) => match golem.species {
|
Body::Golem(golem) => match golem.species {
|
||||||
golem::Species::StoneGolem => Loadout {
|
golem::Species::StoneGolem => Loadout {
|
||||||
|
@ -33,16 +33,11 @@ pub struct Stage {
|
|||||||
pub forward_movement: f32,
|
pub forward_movement: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A sequence of attacks that can incrementally become faster and more
|
|
||||||
/// damaging.
|
|
||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct Data {
|
/// Separated out to condense update portions of character state
|
||||||
/// Indicates what stage the combo is in
|
pub struct StaticData {
|
||||||
pub stage: u32,
|
|
||||||
/// Indicates number of stages in combo
|
/// Indicates number of stages in combo
|
||||||
pub num_stages: u32,
|
pub num_stages: u32,
|
||||||
/// Number of consecutive strikes
|
|
||||||
pub combo: u32,
|
|
||||||
/// Data for each stage
|
/// Data for each stage
|
||||||
pub stage_data: Vec<Stage>,
|
pub stage_data: Vec<Stage>,
|
||||||
/// Initial energy gain per strike
|
/// Initial energy gain per strike
|
||||||
@ -51,12 +46,6 @@ pub struct Data {
|
|||||||
pub max_energy_gain: u32,
|
pub max_energy_gain: u32,
|
||||||
/// Energy gain increase per combo
|
/// Energy gain increase per combo
|
||||||
pub energy_increase: u32,
|
pub energy_increase: u32,
|
||||||
/// 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
|
/// (100% - speed_increase) is percentage speed increases from current to
|
||||||
/// max when combo increases
|
/// max when combo increases
|
||||||
pub speed_increase: f32,
|
pub speed_increase: f32,
|
||||||
@ -65,6 +54,24 @@ pub struct Data {
|
|||||||
/// Whether the state can be interrupted by other abilities
|
/// Whether the state can be interrupted by other abilities
|
||||||
pub is_interruptible: bool,
|
pub is_interruptible: bool,
|
||||||
}
|
}
|
||||||
|
/// A sequence of attacks that can incrementally become faster and more
|
||||||
|
/// damaging.
|
||||||
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
pub struct Data {
|
||||||
|
/// Struct containing data that does not change over the course of the
|
||||||
|
/// character state
|
||||||
|
pub static_data: StaticData,
|
||||||
|
/// Indicates what stage the combo is in
|
||||||
|
pub stage: u32,
|
||||||
|
/// Number of consecutive strikes
|
||||||
|
pub combo: u32,
|
||||||
|
/// 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,
|
||||||
|
}
|
||||||
|
|
||||||
impl CharacterBehavior for Data {
|
impl CharacterBehavior for Data {
|
||||||
fn behavior(&self, data: &JoinData) -> StateUpdate {
|
fn behavior(&self, data: &JoinData) -> StateUpdate {
|
||||||
@ -76,7 +83,7 @@ impl CharacterBehavior for Data {
|
|||||||
let stage_index = (self.stage - 1) as usize;
|
let stage_index = (self.stage - 1) as usize;
|
||||||
|
|
||||||
// Allows for other states to interrupt this state
|
// Allows for other states to interrupt this state
|
||||||
if self.is_interruptible && !data.inputs.primary.is_pressed() {
|
if self.static_data.is_interruptible && !data.inputs.primary.is_pressed() {
|
||||||
handle_interrupt(data, &mut update);
|
handle_interrupt(data, &mut update);
|
||||||
match update.character {
|
match update.character {
|
||||||
CharacterState::ComboMelee(_) => {},
|
CharacterState::ComboMelee(_) => {},
|
||||||
@ -86,211 +93,177 @@ impl CharacterBehavior for Data {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.stage_section == StageSection::Buildup
|
match self.stage_section {
|
||||||
&& self.timer < self.stage_data[stage_index].base_buildup_duration
|
StageSection::Buildup => {
|
||||||
{
|
if self.timer < self.static_data.stage_data[stage_index].base_buildup_duration {
|
||||||
// Build up
|
// Build up
|
||||||
update.character = CharacterState::ComboMelee(Data {
|
update.character = CharacterState::ComboMelee(Data {
|
||||||
stage: self.stage,
|
static_data: self.static_data.clone(),
|
||||||
num_stages: self.num_stages,
|
stage: self.stage,
|
||||||
combo: self.combo,
|
combo: self.combo,
|
||||||
stage_data: self.stage_data.clone(),
|
timer: self
|
||||||
initial_energy_gain: self.initial_energy_gain,
|
.timer
|
||||||
max_energy_gain: self.max_energy_gain,
|
.checked_add(Duration::from_secs_f32(
|
||||||
energy_increase: self.energy_increase,
|
(1.0 + self.static_data.max_speed_increase
|
||||||
timer: self
|
* (1.0
|
||||||
.timer
|
- self.static_data.speed_increase.powi(self.combo as i32)))
|
||||||
.checked_add(Duration::from_secs_f32(
|
* data.dt.0,
|
||||||
(1.0 + self.max_speed_increase
|
))
|
||||||
* (1.0 - self.speed_increase.powi(self.combo as i32)))
|
.unwrap_or_default(),
|
||||||
* data.dt.0,
|
stage_section: self.stage_section,
|
||||||
))
|
next_stage: self.next_stage,
|
||||||
.unwrap_or_default(),
|
});
|
||||||
stage_section: self.stage_section,
|
} else {
|
||||||
next_stage: self.next_stage,
|
// Transitions to swing section of stage
|
||||||
speed_increase: self.speed_increase,
|
update.character = CharacterState::ComboMelee(Data {
|
||||||
max_speed_increase: self.max_speed_increase,
|
static_data: self.static_data.clone(),
|
||||||
is_interruptible: self.is_interruptible,
|
stage: self.stage,
|
||||||
});
|
combo: self.combo,
|
||||||
} else if self.stage_section == StageSection::Buildup {
|
timer: Duration::default(),
|
||||||
// Transitions to swing section of stage
|
stage_section: StageSection::Swing,
|
||||||
update.character = CharacterState::ComboMelee(Data {
|
next_stage: self.next_stage,
|
||||||
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,
|
|
||||||
timer: Duration::default(),
|
|
||||||
stage_section: StageSection::Swing,
|
|
||||||
next_stage: self.next_stage,
|
|
||||||
speed_increase: self.speed_increase,
|
|
||||||
max_speed_increase: self.max_speed_increase,
|
|
||||||
is_interruptible: self.is_interruptible,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Hit attempt
|
// Hit attempt
|
||||||
data.updater.insert(data.entity, Attacking {
|
data.updater.insert(data.entity, Attacking {
|
||||||
base_healthchange: -((self.stage_data[stage_index].max_damage.min(
|
base_healthchange: -((self.static_data.stage_data[stage_index]
|
||||||
self.stage_data[stage_index].base_damage
|
.max_damage
|
||||||
+ self.combo / self.num_stages
|
.min(
|
||||||
* self.stage_data[stage_index].damage_increase,
|
self.static_data.stage_data[stage_index].base_damage
|
||||||
)) as i32),
|
+ self.combo / self.static_data.num_stages
|
||||||
range: self.stage_data[stage_index].range,
|
* self.static_data.stage_data[stage_index].damage_increase,
|
||||||
max_angle: self.stage_data[stage_index].angle.to_radians(),
|
)) as i32),
|
||||||
applied: false,
|
range: self.static_data.stage_data[stage_index].range,
|
||||||
hit_count: 0,
|
max_angle: self.static_data.stage_data[stage_index].angle.to_radians(),
|
||||||
knockback: self.stage_data[stage_index].knockback,
|
applied: false,
|
||||||
});
|
hit_count: 0,
|
||||||
} else if self.stage_section == StageSection::Swing
|
knockback: self.static_data.stage_data[stage_index].knockback,
|
||||||
&& self.timer < self.stage_data[stage_index].base_swing_duration
|
});
|
||||||
{
|
}
|
||||||
// Forward movement
|
},
|
||||||
forward_move(
|
StageSection::Swing => {
|
||||||
data,
|
if self.timer < self.static_data.stage_data[stage_index].base_swing_duration {
|
||||||
&mut update,
|
// Forward movement
|
||||||
0.3,
|
forward_move(
|
||||||
self.stage_data[stage_index].forward_movement,
|
data,
|
||||||
);
|
&mut update,
|
||||||
|
0.3,
|
||||||
|
self.static_data.stage_data[stage_index].forward_movement,
|
||||||
|
);
|
||||||
|
|
||||||
// Swings
|
// Swings
|
||||||
update.character = CharacterState::ComboMelee(Data {
|
update.character = CharacterState::ComboMelee(Data {
|
||||||
stage: self.stage,
|
static_data: self.static_data.clone(),
|
||||||
num_stages: self.num_stages,
|
stage: self.stage,
|
||||||
combo: self.combo,
|
combo: self.combo,
|
||||||
stage_data: self.stage_data.clone(),
|
timer: self
|
||||||
initial_energy_gain: self.initial_energy_gain,
|
.timer
|
||||||
max_energy_gain: self.max_energy_gain,
|
.checked_add(Duration::from_secs_f32(
|
||||||
energy_increase: self.energy_increase,
|
(1.0 + self.static_data.max_speed_increase
|
||||||
timer: self
|
* (1.0
|
||||||
.timer
|
- self.static_data.speed_increase.powi(self.combo as i32)))
|
||||||
.checked_add(Duration::from_secs_f32(
|
* data.dt.0,
|
||||||
(1.0 + self.max_speed_increase
|
))
|
||||||
* (1.0 - self.speed_increase.powi(self.combo as i32)))
|
.unwrap_or_default(),
|
||||||
* data.dt.0,
|
stage_section: self.stage_section,
|
||||||
))
|
next_stage: self.next_stage,
|
||||||
.unwrap_or_default(),
|
});
|
||||||
stage_section: self.stage_section,
|
} else {
|
||||||
next_stage: self.next_stage,
|
// Transitions to recover section of stage
|
||||||
speed_increase: self.speed_increase,
|
update.character = CharacterState::ComboMelee(Data {
|
||||||
max_speed_increase: self.max_speed_increase,
|
static_data: self.static_data.clone(),
|
||||||
is_interruptible: self.is_interruptible,
|
stage: self.stage,
|
||||||
});
|
combo: self.combo,
|
||||||
} else if self.stage_section == StageSection::Swing {
|
timer: Duration::default(),
|
||||||
// Transitions to recover section of stage
|
stage_section: StageSection::Recover,
|
||||||
update.character = CharacterState::ComboMelee(Data {
|
next_stage: self.next_stage,
|
||||||
stage: self.stage,
|
});
|
||||||
num_stages: self.num_stages,
|
}
|
||||||
combo: self.combo,
|
},
|
||||||
stage_data: self.stage_data.clone(),
|
StageSection::Recover => {
|
||||||
initial_energy_gain: self.initial_energy_gain,
|
if self.timer < self.static_data.stage_data[stage_index].base_recover_duration {
|
||||||
max_energy_gain: self.max_energy_gain,
|
// Recovers
|
||||||
energy_increase: self.energy_increase,
|
if data.inputs.primary.is_pressed() {
|
||||||
timer: Duration::default(),
|
// Checks if state will transition to next stage after recover
|
||||||
stage_section: StageSection::Recover,
|
update.character = CharacterState::ComboMelee(Data {
|
||||||
next_stage: self.next_stage,
|
static_data: self.static_data.clone(),
|
||||||
speed_increase: self.speed_increase,
|
stage: self.stage,
|
||||||
max_speed_increase: self.max_speed_increase,
|
combo: self.combo,
|
||||||
is_interruptible: self.is_interruptible,
|
timer: self
|
||||||
});
|
.timer
|
||||||
} else if self.stage_section == StageSection::Recover
|
.checked_add(Duration::from_secs_f32(
|
||||||
&& self.timer < self.stage_data[stage_index].base_recover_duration
|
(1.0 + self.static_data.max_speed_increase
|
||||||
{
|
* (1.0
|
||||||
// Recovers
|
- self
|
||||||
if data.inputs.primary.is_pressed() {
|
.static_data
|
||||||
// Checks if state will transition to next stage after recover
|
.speed_increase
|
||||||
update.character = CharacterState::ComboMelee(Data {
|
.powi(self.combo as i32)))
|
||||||
stage: self.stage,
|
* data.dt.0,
|
||||||
num_stages: self.num_stages,
|
))
|
||||||
combo: self.combo,
|
.unwrap_or_default(),
|
||||||
stage_data: self.stage_data.clone(),
|
stage_section: self.stage_section,
|
||||||
initial_energy_gain: self.initial_energy_gain,
|
next_stage: true,
|
||||||
max_energy_gain: self.max_energy_gain,
|
});
|
||||||
energy_increase: self.energy_increase,
|
} else {
|
||||||
timer: self
|
update.character = CharacterState::ComboMelee(Data {
|
||||||
.timer
|
static_data: self.static_data.clone(),
|
||||||
.checked_add(Duration::from_secs_f32(
|
stage: self.stage,
|
||||||
(1.0 + self.max_speed_increase
|
combo: self.combo,
|
||||||
* (1.0 - self.speed_increase.powi(self.combo as i32)))
|
timer: self
|
||||||
* data.dt.0,
|
.timer
|
||||||
))
|
.checked_add(Duration::from_secs_f32(
|
||||||
.unwrap_or_default(),
|
(1.0 + self.static_data.max_speed_increase
|
||||||
stage_section: self.stage_section,
|
* (1.0
|
||||||
next_stage: true,
|
- self
|
||||||
speed_increase: self.speed_increase,
|
.static_data
|
||||||
max_speed_increase: self.max_speed_increase,
|
.speed_increase
|
||||||
is_interruptible: self.is_interruptible,
|
.powi(self.combo as i32)))
|
||||||
});
|
* data.dt.0,
|
||||||
} else {
|
))
|
||||||
update.character = CharacterState::ComboMelee(Data {
|
.unwrap_or_default(),
|
||||||
stage: self.stage,
|
stage_section: self.stage_section,
|
||||||
num_stages: self.num_stages,
|
next_stage: self.next_stage,
|
||||||
combo: self.combo,
|
});
|
||||||
stage_data: self.stage_data.clone(),
|
}
|
||||||
initial_energy_gain: self.initial_energy_gain,
|
} else if self.next_stage {
|
||||||
max_energy_gain: self.max_energy_gain,
|
// Transitions to buildup section of next stage
|
||||||
energy_increase: self.energy_increase,
|
update.character = CharacterState::ComboMelee(Data {
|
||||||
timer: self
|
static_data: self.static_data.clone(),
|
||||||
.timer
|
stage: (self.stage % self.static_data.num_stages) + 1,
|
||||||
.checked_add(Duration::from_secs_f32(
|
combo: self.combo,
|
||||||
(1.0 + self.max_speed_increase
|
timer: Duration::default(),
|
||||||
* (1.0 - self.speed_increase.powi(self.combo as i32)))
|
stage_section: StageSection::Buildup,
|
||||||
* data.dt.0,
|
next_stage: false,
|
||||||
))
|
});
|
||||||
.unwrap_or_default(),
|
} else {
|
||||||
stage_section: self.stage_section,
|
// Done
|
||||||
next_stage: self.next_stage,
|
update.character = CharacterState::Wielding;
|
||||||
speed_increase: self.speed_increase,
|
// Make sure attack component is removed
|
||||||
max_speed_increase: self.max_speed_increase,
|
data.updater.remove::<Attacking>(data.entity);
|
||||||
is_interruptible: self.is_interruptible,
|
}
|
||||||
});
|
},
|
||||||
}
|
_ => {
|
||||||
} else if self.next_stage {
|
// If it somehow ends up in an incorrect stage section
|
||||||
// Transitions to buildup section of next stage
|
update.character = CharacterState::Wielding;
|
||||||
update.character = CharacterState::ComboMelee(Data {
|
// Make sure attack component is removed
|
||||||
stage: (self.stage % self.num_stages) + 1,
|
data.updater.remove::<Attacking>(data.entity);
|
||||||
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,
|
|
||||||
timer: Duration::default(),
|
|
||||||
stage_section: StageSection::Buildup,
|
|
||||||
next_stage: false,
|
|
||||||
speed_increase: self.speed_increase,
|
|
||||||
max_speed_increase: self.max_speed_increase,
|
|
||||||
is_interruptible: self.is_interruptible,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// Done
|
|
||||||
update.character = CharacterState::Wielding;
|
|
||||||
// Make sure attack component is removed
|
|
||||||
data.updater.remove::<Attacking>(data.entity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grant energy on successful hit
|
// Grant energy on successful hit
|
||||||
if let Some(attack) = data.attacking {
|
if let Some(attack) = data.attacking {
|
||||||
if attack.applied && attack.hit_count > 0 {
|
if attack.applied && attack.hit_count > 0 {
|
||||||
let energy = self
|
let energy = self.static_data.max_energy_gain.min(
|
||||||
.max_energy_gain
|
self.static_data.initial_energy_gain
|
||||||
.min(self.initial_energy_gain + self.combo * self.energy_increase)
|
+ self.combo * self.static_data.energy_increase,
|
||||||
as i32;
|
) as i32;
|
||||||
update.character = CharacterState::ComboMelee(Data {
|
update.character = CharacterState::ComboMelee(Data {
|
||||||
|
static_data: self.static_data.clone(),
|
||||||
stage: self.stage,
|
stage: self.stage,
|
||||||
num_stages: self.num_stages,
|
|
||||||
combo: self.combo + 1,
|
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,
|
|
||||||
timer: self.timer,
|
timer: self.timer,
|
||||||
stage_section: self.stage_section,
|
stage_section: self.stage_section,
|
||||||
next_stage: self.next_stage,
|
next_stage: self.next_stage,
|
||||||
speed_increase: self.speed_increase,
|
|
||||||
max_speed_increase: self.max_speed_increase,
|
|
||||||
is_interruptible: self.is_interruptible,
|
|
||||||
});
|
});
|
||||||
data.updater.remove::<Attacking>(data.entity);
|
data.updater.remove::<Attacking>(data.entity);
|
||||||
update.energy.change_by(energy, EnergySource::HitEnemy);
|
update.energy.change_by(energy, EnergySource::HitEnemy);
|
||||||
|
@ -73,86 +73,10 @@ impl CharacterBehavior for Data {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.stage_section == StageSection::Buildup
|
match self.stage_section {
|
||||||
&& self.timer < self.static_data.buildup_duration
|
StageSection::Buildup => {
|
||||||
{
|
if self.timer < self.static_data.buildup_duration {
|
||||||
// Build up
|
// Build up
|
||||||
update.character = CharacterState::DashMelee(Data {
|
|
||||||
static_data: self.static_data,
|
|
||||||
end_charge: self.end_charge,
|
|
||||||
timer: self
|
|
||||||
.timer
|
|
||||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
|
||||||
.unwrap_or_default(),
|
|
||||||
stage_section: self.stage_section,
|
|
||||||
exhausted: self.exhausted,
|
|
||||||
})
|
|
||||||
} else if self.stage_section == StageSection::Buildup {
|
|
||||||
// Transitions to charge section of stage
|
|
||||||
update.character = CharacterState::DashMelee(Data {
|
|
||||||
static_data: self.static_data,
|
|
||||||
end_charge: self.end_charge,
|
|
||||||
timer: Duration::default(),
|
|
||||||
stage_section: StageSection::Charge,
|
|
||||||
exhausted: self.exhausted,
|
|
||||||
})
|
|
||||||
} else if self.stage_section == StageSection::Charge
|
|
||||||
&& (self.timer < self.static_data.charge_duration
|
|
||||||
|| (self.static_data.infinite_charge && data.inputs.secondary.is_pressed()))
|
|
||||||
&& update.energy.current() > 0
|
|
||||||
&& !self.end_charge
|
|
||||||
{
|
|
||||||
// Forward movement
|
|
||||||
forward_move(data, &mut update, 0.1, self.static_data.forward_speed);
|
|
||||||
|
|
||||||
// Hit attempt (also checks if player is moving)
|
|
||||||
if !self.exhausted && update.vel.0.distance_squared(Vec3::zero()) > 1.0 {
|
|
||||||
let charge_frac = (self.timer.as_secs_f32()
|
|
||||||
/ self.static_data.charge_duration.as_secs_f32())
|
|
||||||
.min(1.0);
|
|
||||||
let damage = (self.static_data.max_damage as f32
|
|
||||||
- self.static_data.base_damage as f32)
|
|
||||||
* charge_frac
|
|
||||||
+ self.static_data.base_damage as f32;
|
|
||||||
let knockback = (self.static_data.max_knockback - self.static_data.base_knockback)
|
|
||||||
* charge_frac
|
|
||||||
+ self.static_data.base_knockback;
|
|
||||||
data.updater.insert(data.entity, Attacking {
|
|
||||||
base_healthchange: -damage as i32,
|
|
||||||
range: self.static_data.range,
|
|
||||||
max_angle: self.static_data.angle.to_radians(),
|
|
||||||
applied: false,
|
|
||||||
hit_count: 0,
|
|
||||||
knockback,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// This logic basically just decides if a charge should end, and prevents the
|
|
||||||
// character state spamming attacks while checking if it has hit something
|
|
||||||
if !self.exhausted {
|
|
||||||
update.character = CharacterState::DashMelee(Data {
|
|
||||||
static_data: self.static_data,
|
|
||||||
end_charge: self.end_charge,
|
|
||||||
timer: self
|
|
||||||
.timer
|
|
||||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
|
||||||
.unwrap_or_default(),
|
|
||||||
stage_section: StageSection::Charge,
|
|
||||||
exhausted: true,
|
|
||||||
})
|
|
||||||
} else if let Some(attack) = data.attacking {
|
|
||||||
if attack.applied && attack.hit_count > 0 {
|
|
||||||
update.character = CharacterState::DashMelee(Data {
|
|
||||||
static_data: self.static_data,
|
|
||||||
end_charge: !self.static_data.infinite_charge,
|
|
||||||
timer: self
|
|
||||||
.timer
|
|
||||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
|
||||||
.unwrap_or_default(),
|
|
||||||
stage_section: StageSection::Charge,
|
|
||||||
exhausted: false,
|
|
||||||
})
|
|
||||||
} else if attack.applied {
|
|
||||||
update.character = CharacterState::DashMelee(Data {
|
update.character = CharacterState::DashMelee(Data {
|
||||||
static_data: self.static_data,
|
static_data: self.static_data,
|
||||||
end_charge: self.end_charge,
|
end_charge: self.end_charge,
|
||||||
@ -160,90 +84,173 @@ impl CharacterBehavior for Data {
|
|||||||
.timer
|
.timer
|
||||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
stage_section: StageSection::Charge,
|
stage_section: self.stage_section,
|
||||||
exhausted: false,
|
exhausted: self.exhausted,
|
||||||
})
|
});
|
||||||
} else {
|
} else {
|
||||||
|
// Transitions to charge section of stage
|
||||||
update.character = CharacterState::DashMelee(Data {
|
update.character = CharacterState::DashMelee(Data {
|
||||||
static_data: self.static_data,
|
static_data: self.static_data,
|
||||||
end_charge: !self.static_data.infinite_charge,
|
end_charge: self.end_charge,
|
||||||
|
timer: Duration::default(),
|
||||||
|
stage_section: StageSection::Charge,
|
||||||
|
exhausted: self.exhausted,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
StageSection::Charge => {
|
||||||
|
if (self.timer < self.static_data.charge_duration
|
||||||
|
|| (self.static_data.infinite_charge && data.inputs.secondary.is_pressed()))
|
||||||
|
&& update.energy.current() > 0
|
||||||
|
&& !self.end_charge
|
||||||
|
{
|
||||||
|
// Forward movement
|
||||||
|
forward_move(data, &mut update, 0.1, self.static_data.forward_speed);
|
||||||
|
|
||||||
|
// Hit attempt (also checks if player is moving)
|
||||||
|
if !self.exhausted && update.vel.0.distance_squared(Vec3::zero()) > 1.0 {
|
||||||
|
let charge_frac = (self.timer.as_secs_f32()
|
||||||
|
/ self.static_data.charge_duration.as_secs_f32())
|
||||||
|
.min(1.0);
|
||||||
|
let damage = (self.static_data.max_damage as f32
|
||||||
|
- self.static_data.base_damage as f32)
|
||||||
|
* charge_frac
|
||||||
|
+ self.static_data.base_damage as f32;
|
||||||
|
let knockback = (self.static_data.max_knockback
|
||||||
|
- self.static_data.base_knockback)
|
||||||
|
* charge_frac
|
||||||
|
+ self.static_data.base_knockback;
|
||||||
|
data.updater.insert(data.entity, Attacking {
|
||||||
|
base_healthchange: -damage as i32,
|
||||||
|
range: self.static_data.range,
|
||||||
|
max_angle: self.static_data.angle.to_radians(),
|
||||||
|
applied: false,
|
||||||
|
hit_count: 0,
|
||||||
|
knockback,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// This logic basically just decides if a charge should end, and prevents the
|
||||||
|
// character state spamming attacks while checking if it has hit something
|
||||||
|
if !self.exhausted {
|
||||||
|
update.character = CharacterState::DashMelee(Data {
|
||||||
|
static_data: self.static_data,
|
||||||
|
end_charge: self.end_charge,
|
||||||
|
timer: self
|
||||||
|
.timer
|
||||||
|
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||||
|
.unwrap_or_default(),
|
||||||
|
stage_section: StageSection::Charge,
|
||||||
|
exhausted: true,
|
||||||
|
})
|
||||||
|
} else if let Some(attack) = data.attacking {
|
||||||
|
if attack.applied && attack.hit_count > 0 {
|
||||||
|
update.character = CharacterState::DashMelee(Data {
|
||||||
|
static_data: self.static_data,
|
||||||
|
end_charge: !self.static_data.infinite_charge,
|
||||||
|
timer: self
|
||||||
|
.timer
|
||||||
|
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||||
|
.unwrap_or_default(),
|
||||||
|
stage_section: StageSection::Charge,
|
||||||
|
exhausted: false,
|
||||||
|
})
|
||||||
|
} else if attack.applied {
|
||||||
|
update.character = CharacterState::DashMelee(Data {
|
||||||
|
static_data: self.static_data,
|
||||||
|
end_charge: self.end_charge,
|
||||||
|
timer: self
|
||||||
|
.timer
|
||||||
|
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||||
|
.unwrap_or_default(),
|
||||||
|
stage_section: StageSection::Charge,
|
||||||
|
exhausted: false,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
update.character = CharacterState::DashMelee(Data {
|
||||||
|
static_data: self.static_data,
|
||||||
|
end_charge: !self.static_data.infinite_charge,
|
||||||
|
timer: self
|
||||||
|
.timer
|
||||||
|
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||||
|
.unwrap_or_default(),
|
||||||
|
stage_section: StageSection::Charge,
|
||||||
|
exhausted: self.exhausted,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
update.character = CharacterState::DashMelee(Data {
|
||||||
|
static_data: self.static_data,
|
||||||
|
end_charge: !self.static_data.infinite_charge,
|
||||||
|
timer: self
|
||||||
|
.timer
|
||||||
|
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||||
|
.unwrap_or_default(),
|
||||||
|
stage_section: StageSection::Charge,
|
||||||
|
exhausted: self.exhausted,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Consumes energy if there's enough left and charge has not stopped
|
||||||
|
update.energy.change_by(
|
||||||
|
-(self.static_data.energy_drain as f32 * data.dt.0) as i32,
|
||||||
|
EnergySource::Ability,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// Transitions to swing section of stage
|
||||||
|
update.character = CharacterState::DashMelee(Data {
|
||||||
|
static_data: self.static_data,
|
||||||
|
end_charge: self.end_charge,
|
||||||
|
timer: Duration::default(),
|
||||||
|
stage_section: StageSection::Swing,
|
||||||
|
exhausted: self.exhausted,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
StageSection::Swing => {
|
||||||
|
if self.timer < self.static_data.swing_duration {
|
||||||
|
// Swings
|
||||||
|
update.character = CharacterState::DashMelee(Data {
|
||||||
|
static_data: self.static_data,
|
||||||
|
end_charge: self.end_charge,
|
||||||
timer: self
|
timer: self
|
||||||
.timer
|
.timer
|
||||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
stage_section: StageSection::Charge,
|
stage_section: self.stage_section,
|
||||||
exhausted: self.exhausted,
|
exhausted: self.exhausted,
|
||||||
})
|
});
|
||||||
|
} else {
|
||||||
|
// Transitions to recover section of stage
|
||||||
|
update.character = CharacterState::DashMelee(Data {
|
||||||
|
static_data: self.static_data,
|
||||||
|
end_charge: self.end_charge,
|
||||||
|
timer: Duration::default(),
|
||||||
|
stage_section: StageSection::Recover,
|
||||||
|
exhausted: self.exhausted,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
},
|
||||||
update.character = CharacterState::DashMelee(Data {
|
StageSection::Recover => {
|
||||||
static_data: self.static_data,
|
if self.timer < self.static_data.recover_duration {
|
||||||
end_charge: !self.static_data.infinite_charge,
|
// Recover
|
||||||
timer: self
|
update.character = CharacterState::DashMelee(Data {
|
||||||
.timer
|
static_data: self.static_data,
|
||||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
end_charge: self.end_charge,
|
||||||
.unwrap_or_default(),
|
timer: self
|
||||||
stage_section: StageSection::Charge,
|
.timer
|
||||||
exhausted: self.exhausted,
|
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||||
})
|
.unwrap_or_default(),
|
||||||
}
|
stage_section: self.stage_section,
|
||||||
|
exhausted: self.exhausted,
|
||||||
// Consumes energy if there's enough left and charge has not stopped
|
});
|
||||||
update.energy.change_by(
|
} else {
|
||||||
-(self.static_data.energy_drain as f32 * data.dt.0) as i32,
|
// Done
|
||||||
EnergySource::Ability,
|
update.character = CharacterState::Wielding;
|
||||||
);
|
// Make sure attack component is removed
|
||||||
} else if self.stage_section == StageSection::Charge {
|
data.updater.remove::<Attacking>(data.entity);
|
||||||
// Transitions to swing section of stage
|
}
|
||||||
update.character = CharacterState::DashMelee(Data {
|
},
|
||||||
static_data: self.static_data,
|
|
||||||
end_charge: self.end_charge,
|
|
||||||
timer: Duration::default(),
|
|
||||||
stage_section: StageSection::Swing,
|
|
||||||
exhausted: self.exhausted,
|
|
||||||
})
|
|
||||||
} else if self.stage_section == StageSection::Swing
|
|
||||||
&& self.timer < self.static_data.swing_duration
|
|
||||||
{
|
|
||||||
// Swings
|
|
||||||
update.character = CharacterState::DashMelee(Data {
|
|
||||||
static_data: self.static_data,
|
|
||||||
end_charge: self.end_charge,
|
|
||||||
timer: self
|
|
||||||
.timer
|
|
||||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
|
||||||
.unwrap_or_default(),
|
|
||||||
stage_section: self.stage_section,
|
|
||||||
exhausted: self.exhausted,
|
|
||||||
})
|
|
||||||
} else if self.stage_section == StageSection::Swing {
|
|
||||||
// Transitions to recover section of stage
|
|
||||||
update.character = CharacterState::DashMelee(Data {
|
|
||||||
static_data: self.static_data,
|
|
||||||
end_charge: self.end_charge,
|
|
||||||
timer: Duration::default(),
|
|
||||||
stage_section: StageSection::Recover,
|
|
||||||
exhausted: self.exhausted,
|
|
||||||
})
|
|
||||||
} else if self.stage_section == StageSection::Recover
|
|
||||||
&& self.timer < self.static_data.recover_duration
|
|
||||||
{
|
|
||||||
// Recover
|
|
||||||
update.character = CharacterState::DashMelee(Data {
|
|
||||||
static_data: self.static_data,
|
|
||||||
end_charge: self.end_charge,
|
|
||||||
timer: self
|
|
||||||
.timer
|
|
||||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
|
||||||
.unwrap_or_default(),
|
|
||||||
stage_section: self.stage_section,
|
|
||||||
exhausted: self.exhausted,
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
// Done
|
|
||||||
update.character = CharacterState::Wielding;
|
|
||||||
// Make sure attack component is removed
|
|
||||||
data.updater.remove::<Attacking>(data.entity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
update
|
update
|
||||||
|
@ -70,114 +70,124 @@ impl CharacterBehavior for Data {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.stage_section == StageSection::Buildup
|
match self.stage_section {
|
||||||
&& self.timer < self.static_data.buildup_duration
|
StageSection::Buildup => {
|
||||||
{
|
if self.timer < self.static_data.buildup_duration {
|
||||||
// Build up
|
// Build up
|
||||||
update.character = CharacterState::SpinMelee(Data {
|
update.character = CharacterState::SpinMelee(Data {
|
||||||
static_data: self.static_data,
|
static_data: self.static_data,
|
||||||
timer: self
|
timer: self
|
||||||
.timer
|
.timer
|
||||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
spins_remaining: self.spins_remaining,
|
spins_remaining: self.spins_remaining,
|
||||||
stage_section: self.stage_section,
|
stage_section: self.stage_section,
|
||||||
exhausted: self.exhausted,
|
exhausted: self.exhausted,
|
||||||
});
|
});
|
||||||
} else if self.stage_section == StageSection::Buildup {
|
} else {
|
||||||
// Transitions to swing section of stage
|
// Transitions to swing section of stage
|
||||||
update.character = CharacterState::SpinMelee(Data {
|
update.character = CharacterState::SpinMelee(Data {
|
||||||
static_data: self.static_data,
|
static_data: self.static_data,
|
||||||
timer: Duration::default(),
|
timer: Duration::default(),
|
||||||
spins_remaining: self.spins_remaining,
|
spins_remaining: self.spins_remaining,
|
||||||
stage_section: StageSection::Swing,
|
stage_section: StageSection::Swing,
|
||||||
exhausted: self.exhausted,
|
exhausted: self.exhausted,
|
||||||
});
|
});
|
||||||
} else if !self.exhausted {
|
}
|
||||||
update.character = CharacterState::SpinMelee(Data {
|
},
|
||||||
static_data: self.static_data,
|
StageSection::Swing => {
|
||||||
timer: Duration::default(),
|
if !self.exhausted {
|
||||||
spins_remaining: self.spins_remaining,
|
update.character = CharacterState::SpinMelee(Data {
|
||||||
stage_section: self.stage_section,
|
static_data: self.static_data,
|
||||||
exhausted: true,
|
timer: Duration::default(),
|
||||||
});
|
spins_remaining: self.spins_remaining,
|
||||||
// Hit attempt
|
stage_section: self.stage_section,
|
||||||
data.updater.insert(data.entity, Attacking {
|
exhausted: true,
|
||||||
base_healthchange: -(self.static_data.base_damage as i32),
|
});
|
||||||
range: self.static_data.range,
|
// Hit attempt
|
||||||
max_angle: 180_f32.to_radians(),
|
data.updater.insert(data.entity, Attacking {
|
||||||
applied: false,
|
base_healthchange: -(self.static_data.base_damage as i32),
|
||||||
hit_count: 0,
|
range: self.static_data.range,
|
||||||
knockback: self.static_data.knockback,
|
max_angle: 180_f32.to_radians(),
|
||||||
});
|
applied: false,
|
||||||
} else if self.stage_section == StageSection::Swing
|
hit_count: 0,
|
||||||
&& self.timer < self.static_data.swing_duration
|
knockback: self.static_data.knockback,
|
||||||
{
|
});
|
||||||
if !self.static_data.is_helicopter {
|
} else if self.timer < self.static_data.swing_duration {
|
||||||
forward_move(data, &mut update, 0.1, self.static_data.forward_speed);
|
if !self.static_data.is_helicopter {
|
||||||
handle_orientation(data, &mut update, 1.0);
|
forward_move(data, &mut update, 0.1, self.static_data.forward_speed);
|
||||||
}
|
handle_orientation(data, &mut update, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
// Swings
|
// Swings
|
||||||
update.character = CharacterState::SpinMelee(Data {
|
update.character = CharacterState::SpinMelee(Data {
|
||||||
static_data: self.static_data,
|
static_data: self.static_data,
|
||||||
timer: self
|
timer: self
|
||||||
.timer
|
.timer
|
||||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
spins_remaining: self.spins_remaining,
|
spins_remaining: self.spins_remaining,
|
||||||
stage_section: self.stage_section,
|
stage_section: self.stage_section,
|
||||||
exhausted: self.exhausted,
|
exhausted: self.exhausted,
|
||||||
});
|
});
|
||||||
} else if update.energy.current() >= self.static_data.energy_cost
|
} else if update.energy.current() >= self.static_data.energy_cost
|
||||||
&& (self.spins_remaining != 0
|
&& (self.spins_remaining != 0
|
||||||
|| (self.static_data.is_infinite && data.inputs.secondary.is_pressed()))
|
|| (self.static_data.is_infinite && data.inputs.secondary.is_pressed()))
|
||||||
{
|
{
|
||||||
let new_spins_remaining = if self.static_data.is_infinite {
|
let new_spins_remaining = if self.static_data.is_infinite {
|
||||||
self.spins_remaining
|
self.spins_remaining
|
||||||
} else {
|
} else {
|
||||||
self.spins_remaining - 1
|
self.spins_remaining - 1
|
||||||
};
|
};
|
||||||
update.character = CharacterState::SpinMelee(Data {
|
update.character = CharacterState::SpinMelee(Data {
|
||||||
static_data: self.static_data,
|
static_data: self.static_data,
|
||||||
timer: Duration::default(),
|
timer: Duration::default(),
|
||||||
spins_remaining: new_spins_remaining,
|
spins_remaining: new_spins_remaining,
|
||||||
stage_section: self.stage_section,
|
stage_section: self.stage_section,
|
||||||
exhausted: false,
|
exhausted: false,
|
||||||
});
|
});
|
||||||
// Consumes energy if there's enough left and RMB is held down
|
// Consumes energy if there's enough left and RMB is held down
|
||||||
update.energy.change_by(
|
update.energy.change_by(
|
||||||
-(self.static_data.energy_cost as i32),
|
-(self.static_data.energy_cost as i32),
|
||||||
EnergySource::Ability,
|
EnergySource::Ability,
|
||||||
);
|
);
|
||||||
} else if self.stage_section == StageSection::Swing {
|
} else {
|
||||||
// Transitions to recover section of stage
|
// Transitions to recover section of stage
|
||||||
update.character = CharacterState::SpinMelee(Data {
|
update.character = CharacterState::SpinMelee(Data {
|
||||||
static_data: self.static_data,
|
static_data: self.static_data,
|
||||||
timer: Duration::default(),
|
timer: Duration::default(),
|
||||||
spins_remaining: self.spins_remaining,
|
spins_remaining: self.spins_remaining,
|
||||||
stage_section: StageSection::Recover,
|
stage_section: StageSection::Recover,
|
||||||
exhausted: self.exhausted,
|
exhausted: self.exhausted,
|
||||||
})
|
});
|
||||||
} else if self.stage_section == StageSection::Recover
|
}
|
||||||
&& self.timer < self.static_data.recover_duration
|
},
|
||||||
{
|
StageSection::Recover => {
|
||||||
// Recover
|
if self.timer < self.static_data.recover_duration {
|
||||||
update.character = CharacterState::SpinMelee(Data {
|
// Recover
|
||||||
static_data: self.static_data,
|
update.character = CharacterState::SpinMelee(Data {
|
||||||
timer: self
|
static_data: self.static_data,
|
||||||
.timer
|
timer: self
|
||||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
.timer
|
||||||
.unwrap_or_default(),
|
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||||
spins_remaining: self.spins_remaining,
|
.unwrap_or_default(),
|
||||||
stage_section: self.stage_section,
|
spins_remaining: self.spins_remaining,
|
||||||
exhausted: self.exhausted,
|
stage_section: self.stage_section,
|
||||||
})
|
exhausted: self.exhausted,
|
||||||
} else {
|
});
|
||||||
// Done
|
} else {
|
||||||
update.character = CharacterState::Wielding;
|
// Done
|
||||||
// Make sure attack component is removed
|
update.character = CharacterState::Wielding;
|
||||||
data.updater.remove::<Attacking>(data.entity);
|
// Make sure attack component is removed
|
||||||
|
data.updater.remove::<Attacking>(data.entity);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_ => {
|
||||||
|
// If it somehow ends up in an incorrect stage section
|
||||||
|
update.character = CharacterState::Wielding;
|
||||||
|
// Make sure attack component is removed
|
||||||
|
data.updater.remove::<Attacking>(data.entity);
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
update
|
update
|
||||||
|
@ -193,10 +193,6 @@ impl<'a> System<'a> for Sys {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if entity_other == entity {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let scale_other = scale_other.map(|s| s.0).unwrap_or(1.0);
|
let scale_other = scale_other.map(|s| s.0).unwrap_or(1.0);
|
||||||
let radius_other = collider_other.map(|c| c.get_radius()).unwrap_or(0.5);
|
let radius_other = collider_other.map(|c| c.get_radius()).unwrap_or(0.5);
|
||||||
let z_limits_other = collider_other
|
let z_limits_other = collider_other
|
||||||
|
@ -114,31 +114,33 @@ fn matches_ability_stage() {
|
|||||||
|
|
||||||
let result = CombatEventMapper::map_event(
|
let result = CombatEventMapper::map_event(
|
||||||
&CharacterState::ComboMelee(states::combo_melee::Data {
|
&CharacterState::ComboMelee(states::combo_melee::Data {
|
||||||
|
static_data: states::combo_melee::StaticData {
|
||||||
|
num_stages: 1,
|
||||||
|
stage_data: vec![states::combo_melee::Stage {
|
||||||
|
stage: 1,
|
||||||
|
base_damage: 100,
|
||||||
|
max_damage: 120,
|
||||||
|
damage_increase: 10,
|
||||||
|
knockback: 10.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),
|
||||||
|
forward_movement: 0.5,
|
||||||
|
}],
|
||||||
|
initial_energy_gain: 0,
|
||||||
|
max_energy_gain: 100,
|
||||||
|
energy_increase: 20,
|
||||||
|
speed_increase: 0.05,
|
||||||
|
max_speed_increase: 1.8,
|
||||||
|
is_interruptible: true,
|
||||||
|
},
|
||||||
stage: 1,
|
stage: 1,
|
||||||
num_stages: 1,
|
|
||||||
combo: 0,
|
combo: 0,
|
||||||
stage_data: vec![states::combo_melee::Stage {
|
|
||||||
stage: 1,
|
|
||||||
base_damage: 100,
|
|
||||||
max_damage: 120,
|
|
||||||
damage_increase: 10,
|
|
||||||
knockback: 10.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),
|
|
||||||
forward_movement: 0.5,
|
|
||||||
}],
|
|
||||||
initial_energy_gain: 0,
|
|
||||||
max_energy_gain: 100,
|
|
||||||
energy_increase: 20,
|
|
||||||
timer: Duration::default(),
|
timer: Duration::default(),
|
||||||
stage_section: states::utils::StageSection::Swing,
|
stage_section: states::utils::StageSection::Swing,
|
||||||
next_stage: false,
|
next_stage: false,
|
||||||
speed_increase: 0.05,
|
|
||||||
max_speed_increase: 1.8,
|
|
||||||
is_interruptible: true,
|
|
||||||
}),
|
}),
|
||||||
&PreviousEntityState {
|
&PreviousEntityState {
|
||||||
event: SfxEvent::Idle,
|
event: SfxEvent::Idle,
|
||||||
@ -172,31 +174,33 @@ fn ignores_different_ability_stage() {
|
|||||||
|
|
||||||
let result = CombatEventMapper::map_event(
|
let result = CombatEventMapper::map_event(
|
||||||
&CharacterState::ComboMelee(states::combo_melee::Data {
|
&CharacterState::ComboMelee(states::combo_melee::Data {
|
||||||
|
static_data: states::combo_melee::StaticData {
|
||||||
|
num_stages: 1,
|
||||||
|
stage_data: vec![states::combo_melee::Stage {
|
||||||
|
stage: 1,
|
||||||
|
base_damage: 100,
|
||||||
|
max_damage: 120,
|
||||||
|
damage_increase: 10,
|
||||||
|
knockback: 10.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),
|
||||||
|
forward_movement: 0.5,
|
||||||
|
}],
|
||||||
|
initial_energy_gain: 0,
|
||||||
|
max_energy_gain: 100,
|
||||||
|
energy_increase: 20,
|
||||||
|
speed_increase: 0.05,
|
||||||
|
max_speed_increase: 1.8,
|
||||||
|
is_interruptible: true,
|
||||||
|
},
|
||||||
stage: 1,
|
stage: 1,
|
||||||
num_stages: 1,
|
|
||||||
combo: 0,
|
combo: 0,
|
||||||
stage_data: vec![states::combo_melee::Stage {
|
|
||||||
stage: 1,
|
|
||||||
base_damage: 100,
|
|
||||||
max_damage: 120,
|
|
||||||
damage_increase: 10,
|
|
||||||
knockback: 10.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),
|
|
||||||
forward_movement: 0.5,
|
|
||||||
}],
|
|
||||||
initial_energy_gain: 0,
|
|
||||||
max_energy_gain: 100,
|
|
||||||
energy_increase: 20,
|
|
||||||
timer: Duration::default(),
|
timer: Duration::default(),
|
||||||
stage_section: states::utils::StageSection::Swing,
|
stage_section: states::utils::StageSection::Swing,
|
||||||
next_stage: false,
|
next_stage: false,
|
||||||
speed_increase: 0.05,
|
|
||||||
max_speed_increase: 1.8,
|
|
||||||
is_interruptible: true,
|
|
||||||
}),
|
}),
|
||||||
&PreviousEntityState {
|
&PreviousEntityState {
|
||||||
event: SfxEvent::Idle,
|
event: SfxEvent::Idle,
|
||||||
|
@ -267,7 +267,7 @@ image_ids! {
|
|||||||
fire_spell_1: "voxygen.element.icons.fire_spell_0",
|
fire_spell_1: "voxygen.element.icons.fire_spell_0",
|
||||||
snake_arrow_0: "voxygen.element.icons.snake",
|
snake_arrow_0: "voxygen.element.icons.snake",
|
||||||
heal_0: "voxygen.element.icons.heal_0",
|
heal_0: "voxygen.element.icons.heal_0",
|
||||||
sowrd_whirlwind: "voxygen.element.icons.sword_whirlwind",
|
sword_whirlwind: "voxygen.element.icons.sword_whirlwind",
|
||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
button: "voxygen.element.buttons.button",
|
button: "voxygen.element.buttons.button",
|
||||||
|
@ -145,7 +145,7 @@ impl<'a> SlotKey<HotbarSource<'a>, HotbarImageSource<'a>> for HotbarSlot {
|
|||||||
HotbarImage::Item(key) => item_imgs.img_id_or_not_found_img(key.clone()),
|
HotbarImage::Item(key) => item_imgs.img_id_or_not_found_img(key.clone()),
|
||||||
HotbarImage::SnakeArrow => imgs.snake_arrow_0,
|
HotbarImage::SnakeArrow => imgs.snake_arrow_0,
|
||||||
HotbarImage::Fireball => imgs.fire_spell_1,
|
HotbarImage::Fireball => imgs.fire_spell_1,
|
||||||
HotbarImage::SwordWhirlwind => imgs.sowrd_whirlwind,
|
HotbarImage::SwordWhirlwind => imgs.sword_whirlwind,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -978,19 +978,19 @@ impl FigureMgr {
|
|||||||
let stage_progress = match s.stage_section {
|
let stage_progress = match s.stage_section {
|
||||||
StageSection::Buildup => {
|
StageSection::Buildup => {
|
||||||
stage_time
|
stage_time
|
||||||
/ s.stage_data[stage_index]
|
/ s.static_data.stage_data[stage_index]
|
||||||
.base_buildup_duration
|
.base_buildup_duration
|
||||||
.as_secs_f64()
|
.as_secs_f64()
|
||||||
},
|
},
|
||||||
StageSection::Swing => {
|
StageSection::Swing => {
|
||||||
stage_time
|
stage_time
|
||||||
/ s.stage_data[stage_index]
|
/ s.static_data.stage_data[stage_index]
|
||||||
.base_swing_duration
|
.base_swing_duration
|
||||||
.as_secs_f64()
|
.as_secs_f64()
|
||||||
},
|
},
|
||||||
StageSection::Recover => {
|
StageSection::Recover => {
|
||||||
stage_time
|
stage_time
|
||||||
/ s.stage_data[stage_index]
|
/ s.static_data.stage_data[stage_index]
|
||||||
.base_recover_duration
|
.base_recover_duration
|
||||||
.as_secs_f64()
|
.as_secs_f64()
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user