mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Update triple_strike:
* add knockback * prevent infinite repeat * more dashes
This commit is contained in:
parent
3889ec7292
commit
857652ee23
@ -132,6 +132,7 @@ pub struct Attacking {
|
|||||||
pub max_angle: f32,
|
pub max_angle: f32,
|
||||||
pub applied: bool,
|
pub applied: bool,
|
||||||
pub hit_count: u32,
|
pub hit_count: u32,
|
||||||
|
pub knockback: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Component for Attacking {
|
impl Component for Attacking {
|
||||||
|
@ -48,6 +48,7 @@ impl CharacterBehavior for Data {
|
|||||||
max_angle: self.max_angle.to_radians(),
|
max_angle: self.max_angle.to_radians(),
|
||||||
applied: false,
|
applied: false,
|
||||||
hit_count: 0,
|
hit_count: 0,
|
||||||
|
knockback: 0.0,
|
||||||
});
|
});
|
||||||
|
|
||||||
update.character = CharacterState::BasicMelee(Data {
|
update.character = CharacterState::BasicMelee(Data {
|
||||||
|
@ -58,6 +58,7 @@ impl CharacterBehavior for Data {
|
|||||||
max_angle: 180_f32.to_radians(),
|
max_angle: 180_f32.to_radians(),
|
||||||
applied: false,
|
applied: false,
|
||||||
hit_count: 0,
|
hit_count: 0,
|
||||||
|
knockback: 0.0,
|
||||||
});
|
});
|
||||||
|
|
||||||
update.character = CharacterState::DashMelee(Data {
|
update.character = CharacterState::DashMelee(Data {
|
||||||
|
@ -57,6 +57,7 @@ impl CharacterBehavior for Data {
|
|||||||
max_angle: 75_f32.to_radians(),
|
max_angle: 75_f32.to_radians(),
|
||||||
applied: false,
|
applied: false,
|
||||||
hit_count: 0,
|
hit_count: 0,
|
||||||
|
knockback: 0.0,
|
||||||
});
|
});
|
||||||
|
|
||||||
update.character = CharacterState::TimedCombo(Data {
|
update.character = CharacterState::TimedCombo(Data {
|
||||||
|
@ -60,12 +60,13 @@ impl CharacterBehavior for Data {
|
|||||||
let initialized = true;
|
let initialized = true;
|
||||||
|
|
||||||
// Handling movement
|
// Handling movement
|
||||||
if let Stage::First = self.stage {
|
|
||||||
if stage_time_active < Duration::from_millis(STAGE_DURATION / 3) {
|
if stage_time_active < Duration::from_millis(STAGE_DURATION / 3) {
|
||||||
let adjusted_accel = if data.physics.touch_entity.is_none() {
|
let adjusted_accel = match (self.stage, data.physics.touch_entity.is_none()) {
|
||||||
INITIAL_ACCEL
|
(Stage::First, true) => INITIAL_ACCEL,
|
||||||
} else {
|
(Stage::Second, true) => INITIAL_ACCEL * 0.75,
|
||||||
0.0
|
(Stage::Third, true) => INITIAL_ACCEL * 0.75,
|
||||||
|
(_, _) => 0.0,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Move player forward while in first third of first stage
|
// Move player forward while in first third of first stage
|
||||||
@ -80,9 +81,6 @@ impl CharacterBehavior for Data {
|
|||||||
} else {
|
} else {
|
||||||
handle_orientation(data, &mut update, 10.0);
|
handle_orientation(data, &mut update, 10.0);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
handle_move(data, &mut update);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handling attacking
|
// Handling attacking
|
||||||
update.character = if stage_time_active > Duration::from_millis(STAGE_DURATION / 2)
|
update.character = if stage_time_active > Duration::from_millis(STAGE_DURATION / 2)
|
||||||
@ -101,6 +99,7 @@ impl CharacterBehavior for Data {
|
|||||||
max_angle: 180_f32.to_radians(),
|
max_angle: 180_f32.to_radians(),
|
||||||
applied: false,
|
applied: false,
|
||||||
hit_count: 0,
|
hit_count: 0,
|
||||||
|
knockback: 7.0,
|
||||||
});
|
});
|
||||||
|
|
||||||
CharacterState::TripleStrike(Data {
|
CharacterState::TripleStrike(Data {
|
||||||
@ -113,6 +112,12 @@ impl CharacterBehavior for Data {
|
|||||||
})
|
})
|
||||||
} else if stage_time_active > Duration::from_millis(STAGE_DURATION) {
|
} else if stage_time_active > Duration::from_millis(STAGE_DURATION) {
|
||||||
if should_transition {
|
if should_transition {
|
||||||
|
if let Stage::Third = self.stage {
|
||||||
|
// Make sure attack component is removed
|
||||||
|
data.updater.remove::<Attacking>(data.entity);
|
||||||
|
// Done
|
||||||
|
CharacterState::Wielding
|
||||||
|
} else {
|
||||||
CharacterState::TripleStrike(Data {
|
CharacterState::TripleStrike(Data {
|
||||||
base_damage: self.base_damage,
|
base_damage: self.base_damage,
|
||||||
stage: match self.stage {
|
stage: match self.stage {
|
||||||
@ -125,6 +130,7 @@ impl CharacterBehavior for Data {
|
|||||||
should_transition,
|
should_transition,
|
||||||
initialized,
|
initialized,
|
||||||
})
|
})
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Make sure attack component is removed
|
// Make sure attack component is removed
|
||||||
data.updater.remove::<Attacking>(data.entity);
|
data.updater.remove::<Attacking>(data.entity);
|
||||||
|
@ -159,7 +159,7 @@ pub fn handle_jump(data: &JoinData, update: &mut StateUpdate) {
|
|||||||
|
|
||||||
/// Will attempt to go into `loadout.active_item.ability1`
|
/// Will attempt to go into `loadout.active_item.ability1`
|
||||||
pub fn handle_ability1_input(data: &JoinData, update: &mut StateUpdate) {
|
pub fn handle_ability1_input(data: &JoinData, update: &mut StateUpdate) {
|
||||||
if data.inputs.primary.is_pressed() {
|
if data.inputs.primary.is_just_pressed() {
|
||||||
if let Some(ability) = data
|
if let Some(ability) = data
|
||||||
.loadout
|
.loadout
|
||||||
.active_item
|
.active_item
|
||||||
@ -174,7 +174,7 @@ pub fn handle_ability1_input(data: &JoinData, update: &mut StateUpdate) {
|
|||||||
|
|
||||||
/// Will attempt to go into `loadout.active_item.ability2`
|
/// Will attempt to go into `loadout.active_item.ability2`
|
||||||
pub fn handle_ability2_input(data: &JoinData, update: &mut StateUpdate) {
|
pub fn handle_ability2_input(data: &JoinData, update: &mut StateUpdate) {
|
||||||
if data.inputs.secondary.is_pressed() {
|
if data.inputs.secondary.is_just_pressed() {
|
||||||
if let Some(ability) = data
|
if let Some(ability) = data
|
||||||
.loadout
|
.loadout
|
||||||
.active_item
|
.active_item
|
||||||
@ -189,7 +189,7 @@ pub fn handle_ability2_input(data: &JoinData, update: &mut StateUpdate) {
|
|||||||
|
|
||||||
/// Will attempt to go into `loadout.active_item.ability3`
|
/// Will attempt to go into `loadout.active_item.ability3`
|
||||||
pub fn handle_ability3_input(data: &JoinData, update: &mut StateUpdate) {
|
pub fn handle_ability3_input(data: &JoinData, update: &mut StateUpdate) {
|
||||||
if data.inputs.ability3.is_pressed() {
|
if data.inputs.ability3.is_just_pressed() {
|
||||||
if let Some(ability) = data
|
if let Some(ability) = data
|
||||||
.loadout
|
.loadout
|
||||||
.active_item
|
.active_item
|
||||||
@ -205,7 +205,7 @@ pub fn handle_ability3_input(data: &JoinData, update: &mut StateUpdate) {
|
|||||||
/// Checks that player can perform a dodge, then
|
/// Checks that player can perform a dodge, then
|
||||||
/// attempts to go into `loadout.active_item.dodge_ability`
|
/// attempts to go into `loadout.active_item.dodge_ability`
|
||||||
pub fn handle_dodge_input(data: &JoinData, update: &mut StateUpdate) {
|
pub fn handle_dodge_input(data: &JoinData, update: &mut StateUpdate) {
|
||||||
if data.inputs.roll.is_pressed() {
|
if data.inputs.roll.is_just_pressed() {
|
||||||
if let Some(ability) = data
|
if let Some(ability) = data
|
||||||
.loadout
|
.loadout
|
||||||
.active_item
|
.active_item
|
||||||
|
@ -3,7 +3,7 @@ use crate::{
|
|||||||
Agent, Attacking, Body, CharacterState, Controller, HealthChange, HealthSource, Ori, Pos,
|
Agent, Attacking, Body, CharacterState, Controller, HealthChange, HealthSource, Ori, Pos,
|
||||||
Scale, Stats,
|
Scale, Stats,
|
||||||
},
|
},
|
||||||
event::{EventBus, ServerEvent},
|
event::{EventBus, LocalEvent, ServerEvent},
|
||||||
sync::Uid,
|
sync::Uid,
|
||||||
};
|
};
|
||||||
use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage};
|
use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage};
|
||||||
@ -19,6 +19,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
type SystemData = (
|
type SystemData = (
|
||||||
Entities<'a>,
|
Entities<'a>,
|
||||||
Read<'a, EventBus<ServerEvent>>,
|
Read<'a, EventBus<ServerEvent>>,
|
||||||
|
Read<'a, EventBus<LocalEvent>>,
|
||||||
ReadStorage<'a, Uid>,
|
ReadStorage<'a, Uid>,
|
||||||
ReadStorage<'a, Pos>,
|
ReadStorage<'a, Pos>,
|
||||||
ReadStorage<'a, Ori>,
|
ReadStorage<'a, Ori>,
|
||||||
@ -36,6 +37,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
(
|
(
|
||||||
entities,
|
entities,
|
||||||
server_bus,
|
server_bus,
|
||||||
|
local_bus,
|
||||||
uids,
|
uids,
|
||||||
positions,
|
positions,
|
||||||
orientations,
|
orientations,
|
||||||
@ -49,6 +51,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
): Self::SystemData,
|
): Self::SystemData,
|
||||||
) {
|
) {
|
||||||
let mut server_emitter = server_bus.emitter();
|
let mut server_emitter = server_bus.emitter();
|
||||||
|
let mut local_emitter = local_bus.emitter();
|
||||||
// Attacks
|
// Attacks
|
||||||
for (entity, uid, pos, ori, scale_maybe, agent_maybe, _, _attacker_stats, attack) in (
|
for (entity, uid, pos, ori, scale_maybe, agent_maybe, _, _attacker_stats, attack) in (
|
||||||
&entities,
|
&entities,
|
||||||
@ -128,6 +131,13 @@ impl<'a> System<'a> for Sys {
|
|||||||
cause: HealthSource::Attack { by: *uid },
|
cause: HealthSource::Attack { by: *uid },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
if attack.knockback != 0.0 {
|
||||||
|
local_emitter.emit(LocalEvent::KnockUp {
|
||||||
|
entity: b,
|
||||||
|
dir: ori.0,
|
||||||
|
force: attack.knockback,
|
||||||
|
});
|
||||||
|
}
|
||||||
attack.hit_count += 1;
|
attack.hit_count += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user