mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Addressed comments
This commit is contained in:
parent
8ab0d5e5e0
commit
2ff59c9f60
@ -381,19 +381,21 @@ impl From<&CharacterAbility> for CharacterState {
|
||||
max_speed_increase,
|
||||
is_interruptible,
|
||||
} => 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,
|
||||
num_stages: stage_data.len() as u32,
|
||||
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(),
|
||||
stage_section: StageSection::Buildup,
|
||||
next_stage: false,
|
||||
speed_increase: 1.0 - *speed_increase,
|
||||
max_speed_increase: *max_speed_increase - 1.0,
|
||||
is_interruptible: *is_interruptible,
|
||||
}),
|
||||
CharacterAbility::LeapMelee {
|
||||
energy_cost: _,
|
||||
|
@ -124,67 +124,28 @@ impl LoadoutBuilder {
|
||||
};
|
||||
|
||||
let loadout = match body {
|
||||
Body::Humanoid(_) => match is_giant {
|
||||
true => Loadout {
|
||||
active_item,
|
||||
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 {
|
||||
Body::Humanoid(_) => {
|
||||
if is_giant {
|
||||
Loadout {
|
||||
active_item,
|
||||
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(
|
||||
match rand::thread_rng().gen_range(0, 10) {
|
||||
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",
|
||||
},
|
||||
"common.items.armor.chest.plate_green_0",
|
||||
)),
|
||||
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(
|
||||
"common.items.armor.pants.worker_blue_0",
|
||||
"common.items.armor.pants.plate_green_0",
|
||||
)),
|
||||
foot: Some(Item::new_from_asset_expect(
|
||||
match rand::thread_rng().gen_range(0, 2) {
|
||||
0 => "common.items.armor.foot.leather_0",
|
||||
_ => "common.items.armor.starter.sandals_0",
|
||||
},
|
||||
"common.items.armor.foot.plate_0",
|
||||
)),
|
||||
back: None,
|
||||
ring: None,
|
||||
@ -193,40 +154,84 @@ impl LoadoutBuilder {
|
||||
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(),
|
||||
},
|
||||
}
|
||||
} else {
|
||||
match alignment {
|
||||
Alignment::Npc => Loadout {
|
||||
active_item,
|
||||
second_item: None,
|
||||
shoulder: None,
|
||||
chest: Some(Item::new_from_asset_expect(
|
||||
match rand::thread_rng().gen_range(0, 10) {
|
||||
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(
|
||||
"common.items.armor.belt.leather_0",
|
||||
)),
|
||||
hand: None,
|
||||
pants: Some(Item::new_from_asset_expect(
|
||||
"common.items.armor.pants.worker_blue_0",
|
||||
)),
|
||||
foot: Some(Item::new_from_asset_expect(
|
||||
match rand::thread_rng().gen_range(0, 2) {
|
||||
0 => "common.items.armor.foot.leather_0",
|
||||
_ => "common.items.armor.starter.sandals_0",
|
||||
},
|
||||
)),
|
||||
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 {
|
||||
golem::Species::StoneGolem => Loadout {
|
||||
|
@ -33,16 +33,11 @@ pub struct Stage {
|
||||
pub forward_movement: f32,
|
||||
}
|
||||
|
||||
/// A sequence of attacks that can incrementally become faster and more
|
||||
/// damaging.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Data {
|
||||
/// Indicates what stage the combo is in
|
||||
pub stage: u32,
|
||||
/// Separated out to condense update portions of character state
|
||||
pub struct StaticData {
|
||||
/// Indicates number of stages in combo
|
||||
pub num_stages: u32,
|
||||
/// Number of consecutive strikes
|
||||
pub combo: u32,
|
||||
/// Data for each stage
|
||||
pub stage_data: Vec<Stage>,
|
||||
/// Initial energy gain per strike
|
||||
@ -51,12 +46,6 @@ pub struct Data {
|
||||
pub max_energy_gain: u32,
|
||||
/// Energy gain increase per combo
|
||||
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
|
||||
/// max when combo increases
|
||||
pub speed_increase: f32,
|
||||
@ -65,6 +54,24 @@ pub struct Data {
|
||||
/// Whether the state can be interrupted by other abilities
|
||||
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 {
|
||||
fn behavior(&self, data: &JoinData) -> StateUpdate {
|
||||
@ -76,7 +83,7 @@ impl CharacterBehavior for Data {
|
||||
let stage_index = (self.stage - 1) as usize;
|
||||
|
||||
// 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);
|
||||
match update.character {
|
||||
CharacterState::ComboMelee(_) => {},
|
||||
@ -86,211 +93,177 @@ impl CharacterBehavior for Data {
|
||||
}
|
||||
}
|
||||
|
||||
if self.stage_section == StageSection::Buildup
|
||||
&& self.timer < self.stage_data[stage_index].base_buildup_duration
|
||||
{
|
||||
// Build up
|
||||
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,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(
|
||||
(1.0 + self.max_speed_increase
|
||||
* (1.0 - self.speed_increase.powi(self.combo 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,
|
||||
is_interruptible: self.is_interruptible,
|
||||
});
|
||||
} else if self.stage_section == StageSection::Buildup {
|
||||
// Transitions to swing section of 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,
|
||||
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,
|
||||
});
|
||||
match self.stage_section {
|
||||
StageSection::Buildup => {
|
||||
if self.timer < self.static_data.stage_data[stage_index].base_buildup_duration {
|
||||
// Build up
|
||||
update.character = CharacterState::ComboMelee(Data {
|
||||
static_data: self.static_data.clone(),
|
||||
stage: self.stage,
|
||||
combo: self.combo,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(
|
||||
(1.0 + self.static_data.max_speed_increase
|
||||
* (1.0
|
||||
- self.static_data.speed_increase.powi(self.combo as i32)))
|
||||
* data.dt.0,
|
||||
))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
next_stage: self.next_stage,
|
||||
});
|
||||
} else {
|
||||
// Transitions to swing section of stage
|
||||
update.character = CharacterState::ComboMelee(Data {
|
||||
static_data: self.static_data.clone(),
|
||||
stage: self.stage,
|
||||
combo: self.combo,
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Swing,
|
||||
next_stage: self.next_stage,
|
||||
});
|
||||
|
||||
// Hit attempt
|
||||
data.updater.insert(data.entity, Attacking {
|
||||
base_healthchange: -((self.stage_data[stage_index].max_damage.min(
|
||||
self.stage_data[stage_index].base_damage
|
||||
+ self.combo / self.num_stages
|
||||
* self.stage_data[stage_index].damage_increase,
|
||||
)) as i32),
|
||||
range: self.stage_data[stage_index].range,
|
||||
max_angle: self.stage_data[stage_index].angle.to_radians(),
|
||||
applied: false,
|
||||
hit_count: 0,
|
||||
knockback: self.stage_data[stage_index].knockback,
|
||||
});
|
||||
} else if self.stage_section == StageSection::Swing
|
||||
&& self.timer < self.stage_data[stage_index].base_swing_duration
|
||||
{
|
||||
// Forward movement
|
||||
forward_move(
|
||||
data,
|
||||
&mut update,
|
||||
0.3,
|
||||
self.stage_data[stage_index].forward_movement,
|
||||
);
|
||||
// Hit attempt
|
||||
data.updater.insert(data.entity, Attacking {
|
||||
base_healthchange: -((self.static_data.stage_data[stage_index]
|
||||
.max_damage
|
||||
.min(
|
||||
self.static_data.stage_data[stage_index].base_damage
|
||||
+ self.combo / self.static_data.num_stages
|
||||
* self.static_data.stage_data[stage_index].damage_increase,
|
||||
)) as i32),
|
||||
range: self.static_data.stage_data[stage_index].range,
|
||||
max_angle: self.static_data.stage_data[stage_index].angle.to_radians(),
|
||||
applied: false,
|
||||
hit_count: 0,
|
||||
knockback: self.static_data.stage_data[stage_index].knockback,
|
||||
});
|
||||
}
|
||||
},
|
||||
StageSection::Swing => {
|
||||
if self.timer < self.static_data.stage_data[stage_index].base_swing_duration {
|
||||
// Forward movement
|
||||
forward_move(
|
||||
data,
|
||||
&mut update,
|
||||
0.3,
|
||||
self.static_data.stage_data[stage_index].forward_movement,
|
||||
);
|
||||
|
||||
// Swings
|
||||
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,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(
|
||||
(1.0 + self.max_speed_increase
|
||||
* (1.0 - self.speed_increase.powi(self.combo 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,
|
||||
is_interruptible: self.is_interruptible,
|
||||
});
|
||||
} else if self.stage_section == StageSection::Swing {
|
||||
// Transitions to recover section of 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,
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Recover,
|
||||
next_stage: self.next_stage,
|
||||
speed_increase: self.speed_increase,
|
||||
max_speed_increase: self.max_speed_increase,
|
||||
is_interruptible: self.is_interruptible,
|
||||
});
|
||||
} else if self.stage_section == StageSection::Recover
|
||||
&& self.timer < self.stage_data[stage_index].base_recover_duration
|
||||
{
|
||||
// Recovers
|
||||
if data.inputs.primary.is_pressed() {
|
||||
// Checks if state will transition to next stage after recover
|
||||
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,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(
|
||||
(1.0 + self.max_speed_increase
|
||||
* (1.0 - self.speed_increase.powi(self.combo 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,
|
||||
is_interruptible: self.is_interruptible,
|
||||
});
|
||||
} 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,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(
|
||||
(1.0 + self.max_speed_increase
|
||||
* (1.0 - self.speed_increase.powi(self.combo 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,
|
||||
is_interruptible: self.is_interruptible,
|
||||
});
|
||||
}
|
||||
} else if self.next_stage {
|
||||
// Transitions to buildup section of next stage
|
||||
update.character = CharacterState::ComboMelee(Data {
|
||||
stage: (self.stage % self.num_stages) + 1,
|
||||
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);
|
||||
// Swings
|
||||
update.character = CharacterState::ComboMelee(Data {
|
||||
static_data: self.static_data.clone(),
|
||||
stage: self.stage,
|
||||
combo: self.combo,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(
|
||||
(1.0 + self.static_data.max_speed_increase
|
||||
* (1.0
|
||||
- self.static_data.speed_increase.powi(self.combo as i32)))
|
||||
* data.dt.0,
|
||||
))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
next_stage: self.next_stage,
|
||||
});
|
||||
} else {
|
||||
// Transitions to recover section of stage
|
||||
update.character = CharacterState::ComboMelee(Data {
|
||||
static_data: self.static_data.clone(),
|
||||
stage: self.stage,
|
||||
combo: self.combo,
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Recover,
|
||||
next_stage: self.next_stage,
|
||||
});
|
||||
}
|
||||
},
|
||||
StageSection::Recover => {
|
||||
if self.timer < self.static_data.stage_data[stage_index].base_recover_duration {
|
||||
// Recovers
|
||||
if data.inputs.primary.is_pressed() {
|
||||
// Checks if state will transition to next stage after recover
|
||||
update.character = CharacterState::ComboMelee(Data {
|
||||
static_data: self.static_data.clone(),
|
||||
stage: self.stage,
|
||||
combo: self.combo,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(
|
||||
(1.0 + self.static_data.max_speed_increase
|
||||
* (1.0
|
||||
- self
|
||||
.static_data
|
||||
.speed_increase
|
||||
.powi(self.combo as i32)))
|
||||
* data.dt.0,
|
||||
))
|
||||
.unwrap_or_default(),
|
||||
stage_section: self.stage_section,
|
||||
next_stage: true,
|
||||
});
|
||||
} else {
|
||||
update.character = CharacterState::ComboMelee(Data {
|
||||
static_data: self.static_data.clone(),
|
||||
stage: self.stage,
|
||||
combo: self.combo,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(
|
||||
(1.0 + self.static_data.max_speed_increase
|
||||
* (1.0
|
||||
- self
|
||||
.static_data
|
||||
.speed_increase
|
||||
.powi(self.combo as i32)))
|
||||
* 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
|
||||
update.character = CharacterState::ComboMelee(Data {
|
||||
static_data: self.static_data.clone(),
|
||||
stage: (self.stage % self.static_data.num_stages) + 1,
|
||||
combo: self.combo,
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Buildup,
|
||||
next_stage: false,
|
||||
});
|
||||
} else {
|
||||
// Done
|
||||
update.character = CharacterState::Wielding;
|
||||
// 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);
|
||||
},
|
||||
}
|
||||
|
||||
// Grant energy on successful hit
|
||||
if let Some(attack) = data.attacking {
|
||||
if attack.applied && attack.hit_count > 0 {
|
||||
let energy = self
|
||||
.max_energy_gain
|
||||
.min(self.initial_energy_gain + self.combo * self.energy_increase)
|
||||
as i32;
|
||||
let energy = self.static_data.max_energy_gain.min(
|
||||
self.static_data.initial_energy_gain
|
||||
+ self.combo * self.static_data.energy_increase,
|
||||
) as i32;
|
||||
update.character = CharacterState::ComboMelee(Data {
|
||||
static_data: self.static_data.clone(),
|
||||
stage: self.stage,
|
||||
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,
|
||||
timer: self.timer,
|
||||
stage_section: self.stage_section,
|
||||
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);
|
||||
update.energy.change_by(energy, EnergySource::HitEnemy);
|
||||
|
@ -73,86 +73,10 @@ impl CharacterBehavior for Data {
|
||||
}
|
||||
}
|
||||
|
||||
if self.stage_section == StageSection::Buildup
|
||||
&& self.timer < self.static_data.buildup_duration
|
||||
{
|
||||
// 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 {
|
||||
match self.stage_section {
|
||||
StageSection::Buildup => {
|
||||
if self.timer < self.static_data.buildup_duration {
|
||||
// Build up
|
||||
update.character = CharacterState::DashMelee(Data {
|
||||
static_data: self.static_data,
|
||||
end_charge: self.end_charge,
|
||||
@ -160,90 +84,173 @@ impl CharacterBehavior for Data {
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
stage_section: StageSection::Charge,
|
||||
exhausted: false,
|
||||
})
|
||||
stage_section: self.stage_section,
|
||||
exhausted: self.exhausted,
|
||||
});
|
||||
} else {
|
||||
// Transitions to charge section of stage
|
||||
update.character = CharacterState::DashMelee(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
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
stage_section: StageSection::Charge,
|
||||
stage_section: self.stage_section,
|
||||
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 {
|
||||
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 if self.stage_section == StageSection::Charge {
|
||||
// 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);
|
||||
},
|
||||
StageSection::Recover => {
|
||||
if 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
|
||||
|
@ -70,114 +70,124 @@ impl CharacterBehavior for Data {
|
||||
}
|
||||
}
|
||||
|
||||
if self.stage_section == StageSection::Buildup
|
||||
&& self.timer < self.static_data.buildup_duration
|
||||
{
|
||||
// Build up
|
||||
update.character = CharacterState::SpinMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
spins_remaining: self.spins_remaining,
|
||||
stage_section: self.stage_section,
|
||||
exhausted: self.exhausted,
|
||||
});
|
||||
} else if self.stage_section == StageSection::Buildup {
|
||||
// Transitions to swing section of stage
|
||||
update.character = CharacterState::SpinMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: Duration::default(),
|
||||
spins_remaining: self.spins_remaining,
|
||||
stage_section: StageSection::Swing,
|
||||
exhausted: self.exhausted,
|
||||
});
|
||||
} else if !self.exhausted {
|
||||
update.character = CharacterState::SpinMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: Duration::default(),
|
||||
spins_remaining: self.spins_remaining,
|
||||
stage_section: self.stage_section,
|
||||
exhausted: true,
|
||||
});
|
||||
// Hit attempt
|
||||
data.updater.insert(data.entity, Attacking {
|
||||
base_healthchange: -(self.static_data.base_damage as i32),
|
||||
range: self.static_data.range,
|
||||
max_angle: 180_f32.to_radians(),
|
||||
applied: false,
|
||||
hit_count: 0,
|
||||
knockback: self.static_data.knockback,
|
||||
});
|
||||
} else if self.stage_section == StageSection::Swing
|
||||
&& self.timer < self.static_data.swing_duration
|
||||
{
|
||||
if !self.static_data.is_helicopter {
|
||||
forward_move(data, &mut update, 0.1, self.static_data.forward_speed);
|
||||
handle_orientation(data, &mut update, 1.0);
|
||||
}
|
||||
match self.stage_section {
|
||||
StageSection::Buildup => {
|
||||
if self.timer < self.static_data.buildup_duration {
|
||||
// Build up
|
||||
update.character = CharacterState::SpinMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
spins_remaining: self.spins_remaining,
|
||||
stage_section: self.stage_section,
|
||||
exhausted: self.exhausted,
|
||||
});
|
||||
} else {
|
||||
// Transitions to swing section of stage
|
||||
update.character = CharacterState::SpinMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: Duration::default(),
|
||||
spins_remaining: self.spins_remaining,
|
||||
stage_section: StageSection::Swing,
|
||||
exhausted: self.exhausted,
|
||||
});
|
||||
}
|
||||
},
|
||||
StageSection::Swing => {
|
||||
if !self.exhausted {
|
||||
update.character = CharacterState::SpinMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: Duration::default(),
|
||||
spins_remaining: self.spins_remaining,
|
||||
stage_section: self.stage_section,
|
||||
exhausted: true,
|
||||
});
|
||||
// Hit attempt
|
||||
data.updater.insert(data.entity, Attacking {
|
||||
base_healthchange: -(self.static_data.base_damage as i32),
|
||||
range: self.static_data.range,
|
||||
max_angle: 180_f32.to_radians(),
|
||||
applied: false,
|
||||
hit_count: 0,
|
||||
knockback: self.static_data.knockback,
|
||||
});
|
||||
} else if self.timer < self.static_data.swing_duration {
|
||||
if !self.static_data.is_helicopter {
|
||||
forward_move(data, &mut update, 0.1, self.static_data.forward_speed);
|
||||
handle_orientation(data, &mut update, 1.0);
|
||||
}
|
||||
|
||||
// Swings
|
||||
update.character = CharacterState::SpinMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
spins_remaining: self.spins_remaining,
|
||||
stage_section: self.stage_section,
|
||||
exhausted: self.exhausted,
|
||||
});
|
||||
} else if update.energy.current() >= self.static_data.energy_cost
|
||||
&& (self.spins_remaining != 0
|
||||
|| (self.static_data.is_infinite && data.inputs.secondary.is_pressed()))
|
||||
{
|
||||
let new_spins_remaining = if self.static_data.is_infinite {
|
||||
self.spins_remaining
|
||||
} else {
|
||||
self.spins_remaining - 1
|
||||
};
|
||||
update.character = CharacterState::SpinMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: Duration::default(),
|
||||
spins_remaining: new_spins_remaining,
|
||||
stage_section: self.stage_section,
|
||||
exhausted: false,
|
||||
});
|
||||
// Consumes energy if there's enough left and RMB is held down
|
||||
update.energy.change_by(
|
||||
-(self.static_data.energy_cost as i32),
|
||||
EnergySource::Ability,
|
||||
);
|
||||
} else if self.stage_section == StageSection::Swing {
|
||||
// Transitions to recover section of stage
|
||||
update.character = CharacterState::SpinMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: Duration::default(),
|
||||
spins_remaining: self.spins_remaining,
|
||||
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::SpinMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
spins_remaining: self.spins_remaining,
|
||||
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);
|
||||
// Swings
|
||||
update.character = CharacterState::SpinMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
spins_remaining: self.spins_remaining,
|
||||
stage_section: self.stage_section,
|
||||
exhausted: self.exhausted,
|
||||
});
|
||||
} else if update.energy.current() >= self.static_data.energy_cost
|
||||
&& (self.spins_remaining != 0
|
||||
|| (self.static_data.is_infinite && data.inputs.secondary.is_pressed()))
|
||||
{
|
||||
let new_spins_remaining = if self.static_data.is_infinite {
|
||||
self.spins_remaining
|
||||
} else {
|
||||
self.spins_remaining - 1
|
||||
};
|
||||
update.character = CharacterState::SpinMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: Duration::default(),
|
||||
spins_remaining: new_spins_remaining,
|
||||
stage_section: self.stage_section,
|
||||
exhausted: false,
|
||||
});
|
||||
// Consumes energy if there's enough left and RMB is held down
|
||||
update.energy.change_by(
|
||||
-(self.static_data.energy_cost as i32),
|
||||
EnergySource::Ability,
|
||||
);
|
||||
} else {
|
||||
// Transitions to recover section of stage
|
||||
update.character = CharacterState::SpinMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: Duration::default(),
|
||||
spins_remaining: self.spins_remaining,
|
||||
stage_section: StageSection::Recover,
|
||||
exhausted: self.exhausted,
|
||||
});
|
||||
}
|
||||
},
|
||||
StageSection::Recover => {
|
||||
if self.timer < self.static_data.recover_duration {
|
||||
// Recover
|
||||
update.character = CharacterState::SpinMelee(Data {
|
||||
static_data: self.static_data,
|
||||
timer: self
|
||||
.timer
|
||||
.checked_add(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
spins_remaining: self.spins_remaining,
|
||||
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);
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
// 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
|
||||
|
@ -193,10 +193,6 @@ impl<'a> System<'a> for Sys {
|
||||
continue;
|
||||
}
|
||||
|
||||
if entity_other == entity {
|
||||
continue;
|
||||
}
|
||||
|
||||
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 z_limits_other = collider_other
|
||||
|
@ -114,31 +114,33 @@ fn matches_ability_stage() {
|
||||
|
||||
let result = CombatEventMapper::map_event(
|
||||
&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,
|
||||
num_stages: 1,
|
||||
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(),
|
||||
stage_section: states::utils::StageSection::Swing,
|
||||
next_stage: false,
|
||||
speed_increase: 0.05,
|
||||
max_speed_increase: 1.8,
|
||||
is_interruptible: true,
|
||||
}),
|
||||
&PreviousEntityState {
|
||||
event: SfxEvent::Idle,
|
||||
@ -172,31 +174,33 @@ fn ignores_different_ability_stage() {
|
||||
|
||||
let result = CombatEventMapper::map_event(
|
||||
&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,
|
||||
num_stages: 1,
|
||||
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(),
|
||||
stage_section: states::utils::StageSection::Swing,
|
||||
next_stage: false,
|
||||
speed_increase: 0.05,
|
||||
max_speed_increase: 1.8,
|
||||
is_interruptible: true,
|
||||
}),
|
||||
&PreviousEntityState {
|
||||
event: SfxEvent::Idle,
|
||||
|
@ -267,7 +267,7 @@ image_ids! {
|
||||
fire_spell_1: "voxygen.element.icons.fire_spell_0",
|
||||
snake_arrow_0: "voxygen.element.icons.snake",
|
||||
heal_0: "voxygen.element.icons.heal_0",
|
||||
sowrd_whirlwind: "voxygen.element.icons.sword_whirlwind",
|
||||
sword_whirlwind: "voxygen.element.icons.sword_whirlwind",
|
||||
|
||||
// Buttons
|
||||
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::SnakeArrow => imgs.snake_arrow_0,
|
||||
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 {
|
||||
StageSection::Buildup => {
|
||||
stage_time
|
||||
/ s.stage_data[stage_index]
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_buildup_duration
|
||||
.as_secs_f64()
|
||||
},
|
||||
StageSection::Swing => {
|
||||
stage_time
|
||||
/ s.stage_data[stage_index]
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_swing_duration
|
||||
.as_secs_f64()
|
||||
},
|
||||
StageSection::Recover => {
|
||||
stage_time
|
||||
/ s.stage_data[stage_index]
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_recover_duration
|
||||
.as_secs_f64()
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user