mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Rolling can now interrupt any attack.
This commit is contained in:
parent
7c1b7d1fb0
commit
abc1dd9997
@ -589,6 +589,7 @@ impl From<(&CharacterAbility, AbilityKey)> for CharacterState {
|
|||||||
knockback: *knockback,
|
knockback: *knockback,
|
||||||
range: *range,
|
range: *range,
|
||||||
max_angle: *max_angle,
|
max_angle: *max_angle,
|
||||||
|
ability_key: key,
|
||||||
},
|
},
|
||||||
timer: Duration::default(),
|
timer: Duration::default(),
|
||||||
stage_section: StageSection::Buildup,
|
stage_section: StageSection::Buildup,
|
||||||
@ -741,6 +742,7 @@ impl From<(&CharacterAbility, AbilityKey)> for CharacterState {
|
|||||||
max_angle: *max_angle,
|
max_angle: *max_angle,
|
||||||
forward_leap_strength: *forward_leap_strength,
|
forward_leap_strength: *forward_leap_strength,
|
||||||
vertical_leap_strength: *vertical_leap_strength,
|
vertical_leap_strength: *vertical_leap_strength,
|
||||||
|
ability_key: key,
|
||||||
},
|
},
|
||||||
timer: Duration::default(),
|
timer: Duration::default(),
|
||||||
stage_section: StageSection::Buildup,
|
stage_section: StageSection::Buildup,
|
||||||
@ -877,6 +879,7 @@ impl From<(&CharacterAbility, AbilityKey)> for CharacterState {
|
|||||||
projectile_light: *projectile_light,
|
projectile_light: *projectile_light,
|
||||||
projectile_gravity: *projectile_gravity,
|
projectile_gravity: *projectile_gravity,
|
||||||
projectile_speed: *projectile_speed,
|
projectile_speed: *projectile_speed,
|
||||||
|
ability_key: key,
|
||||||
},
|
},
|
||||||
timer: Duration::default(),
|
timer: Duration::default(),
|
||||||
stage_section: StageSection::Movement,
|
stage_section: StageSection::Movement,
|
||||||
@ -908,6 +911,7 @@ impl From<(&CharacterAbility, AbilityKey)> for CharacterState {
|
|||||||
shockwave_duration: Duration::from_millis(*shockwave_duration),
|
shockwave_duration: Duration::from_millis(*shockwave_duration),
|
||||||
requires_ground: *requires_ground,
|
requires_ground: *requires_ground,
|
||||||
move_efficiency: *move_efficiency,
|
move_efficiency: *move_efficiency,
|
||||||
|
ability_key: key,
|
||||||
},
|
},
|
||||||
timer: Duration::default(),
|
timer: Duration::default(),
|
||||||
stage_section: StageSection::Buildup,
|
stage_section: StageSection::Buildup,
|
||||||
|
@ -63,6 +63,15 @@ impl CharacterBehavior for Data {
|
|||||||
|
|
||||||
handle_move(data, &mut update, 0.4);
|
handle_move(data, &mut update, 0.4);
|
||||||
handle_jump(data, &mut update);
|
handle_jump(data, &mut update);
|
||||||
|
if !ability_key_is_pressed(data, self.static_data.ability_key) {
|
||||||
|
handle_interrupt(data, &mut update, true);
|
||||||
|
match update.character {
|
||||||
|
CharacterState::BasicBeam(_) => {},
|
||||||
|
_ => {
|
||||||
|
return update;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if unwrap_tool_data(data).is_none() {
|
if unwrap_tool_data(data).is_none() {
|
||||||
update.character = CharacterState::Idle;
|
update.character = CharacterState::Idle;
|
||||||
|
@ -24,6 +24,8 @@ pub struct StaticData {
|
|||||||
pub range: f32,
|
pub range: f32,
|
||||||
/// Max angle (45.0 will give you a 90.0 angle window)
|
/// Max angle (45.0 will give you a 90.0 angle window)
|
||||||
pub max_angle: f32,
|
pub max_angle: f32,
|
||||||
|
/// What key is used to press ability
|
||||||
|
pub ability_key: AbilityKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -45,6 +47,15 @@ impl CharacterBehavior for Data {
|
|||||||
|
|
||||||
handle_move(data, &mut update, 0.7);
|
handle_move(data, &mut update, 0.7);
|
||||||
handle_jump(data, &mut update);
|
handle_jump(data, &mut update);
|
||||||
|
if !ability_key_is_pressed(data, self.static_data.ability_key) {
|
||||||
|
handle_interrupt(data, &mut update, true);
|
||||||
|
match update.character {
|
||||||
|
CharacterState::BasicMelee(_) => {},
|
||||||
|
_ => {
|
||||||
|
return update;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
match self.stage_section {
|
match self.stage_section {
|
||||||
StageSection::Buildup => {
|
StageSection::Buildup => {
|
||||||
|
@ -48,6 +48,15 @@ impl CharacterBehavior for Data {
|
|||||||
|
|
||||||
handle_move(data, &mut update, 0.3);
|
handle_move(data, &mut update, 0.3);
|
||||||
handle_jump(data, &mut update);
|
handle_jump(data, &mut update);
|
||||||
|
if !ability_key_is_pressed(data, self.static_data.ability_key) {
|
||||||
|
handle_interrupt(data, &mut update, true);
|
||||||
|
match update.character {
|
||||||
|
CharacterState::BasicRanged(_) => {},
|
||||||
|
_ => {
|
||||||
|
return update;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
match self.stage_section {
|
match self.stage_section {
|
||||||
StageSection::Buildup => {
|
StageSection::Buildup => {
|
||||||
|
@ -59,6 +59,15 @@ impl CharacterBehavior for Data {
|
|||||||
|
|
||||||
handle_move(data, &mut update, 0.7);
|
handle_move(data, &mut update, 0.7);
|
||||||
handle_jump(data, &mut update);
|
handle_jump(data, &mut update);
|
||||||
|
if !ability_key_is_pressed(data, self.static_data.ability_key) {
|
||||||
|
handle_interrupt(data, &mut update, true);
|
||||||
|
match update.character {
|
||||||
|
CharacterState::ChargedMelee(_) => {},
|
||||||
|
_ => {
|
||||||
|
return update;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
match self.stage_section {
|
match self.stage_section {
|
||||||
StageSection::Charge => {
|
StageSection::Charge => {
|
||||||
|
@ -63,6 +63,15 @@ impl CharacterBehavior for Data {
|
|||||||
|
|
||||||
handle_move(data, &mut update, 0.3);
|
handle_move(data, &mut update, 0.3);
|
||||||
handle_jump(data, &mut update);
|
handle_jump(data, &mut update);
|
||||||
|
if !ability_key_is_pressed(data, self.static_data.ability_key) {
|
||||||
|
handle_interrupt(data, &mut update, true);
|
||||||
|
match update.character {
|
||||||
|
CharacterState::ChargedRanged(_) => {},
|
||||||
|
_ => {
|
||||||
|
return update;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
match self.stage_section {
|
match self.stage_section {
|
||||||
StageSection::Buildup => {
|
StageSection::Buildup => {
|
||||||
|
@ -110,20 +110,11 @@ impl CharacterBehavior for Data {
|
|||||||
|
|
||||||
handle_orientation(data, &mut update, 1.0);
|
handle_orientation(data, &mut update, 1.0);
|
||||||
handle_move(data, &mut update, 0.3);
|
handle_move(data, &mut update, 0.3);
|
||||||
|
if !ability_key_is_pressed(data, self.static_data.ability_key) {
|
||||||
let stage_index = (self.stage - 1) as usize;
|
handle_interrupt(data, &mut update, !self.static_data.is_interruptible);
|
||||||
|
|
||||||
// Allows for other states to interrupt this state
|
|
||||||
if self.static_data.is_interruptible
|
|
||||||
&& !ability_key_is_pressed(data, self.static_data.ability_key)
|
|
||||||
{
|
|
||||||
handle_interrupt(data, &mut update);
|
|
||||||
if ability_key_is_pressed(data, AbilityKey::Dodge) {
|
|
||||||
handle_dodge_input(data, &mut update);
|
|
||||||
if let CharacterState::Roll(roll) = &mut update.character {
|
if let CharacterState::Roll(roll) = &mut update.character {
|
||||||
roll.was_combo = Some((self.stage, self.combo));
|
roll.was_combo = Some((self.stage, self.combo));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
match update.character {
|
match update.character {
|
||||||
CharacterState::ComboMelee(_) => {},
|
CharacterState::ComboMelee(_) => {},
|
||||||
_ => {
|
_ => {
|
||||||
@ -132,6 +123,8 @@ impl CharacterBehavior for Data {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let stage_index = (self.stage - 1) as usize;
|
||||||
|
|
||||||
let speed_modifer = 1.0
|
let speed_modifer = 1.0
|
||||||
+ self.static_data.max_speed_increase
|
+ self.static_data.max_speed_increase
|
||||||
* (1.0 - self.static_data.speed_increase.powi(self.combo as i32));
|
* (1.0 - self.static_data.speed_increase.powi(self.combo as i32));
|
||||||
|
@ -66,12 +66,8 @@ impl CharacterBehavior for Data {
|
|||||||
|
|
||||||
handle_orientation(data, &mut update, 1.0);
|
handle_orientation(data, &mut update, 1.0);
|
||||||
handle_move(data, &mut update, 0.1);
|
handle_move(data, &mut update, 0.1);
|
||||||
|
if !ability_key_is_pressed(data, self.static_data.ability_key) {
|
||||||
// Allows for other states to interrupt this state
|
handle_interrupt(data, &mut update, !self.static_data.is_interruptible);
|
||||||
if self.static_data.is_interruptible
|
|
||||||
&& !ability_key_is_pressed(data, self.static_data.ability_key)
|
|
||||||
{
|
|
||||||
handle_interrupt(data, &mut update);
|
|
||||||
match update.character {
|
match update.character {
|
||||||
CharacterState::DashMelee(_) => {},
|
CharacterState::DashMelee(_) => {},
|
||||||
_ => {
|
_ => {
|
||||||
|
@ -30,6 +30,8 @@ pub struct StaticData {
|
|||||||
pub forward_leap_strength: f32,
|
pub forward_leap_strength: f32,
|
||||||
/// Affects how high the player leaps
|
/// Affects how high the player leaps
|
||||||
pub vertical_leap_strength: f32,
|
pub vertical_leap_strength: f32,
|
||||||
|
/// What key is used to press ability
|
||||||
|
pub ability_key: AbilityKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -51,6 +53,15 @@ impl CharacterBehavior for Data {
|
|||||||
|
|
||||||
handle_move(data, &mut update, 0.3);
|
handle_move(data, &mut update, 0.3);
|
||||||
handle_jump(data, &mut update);
|
handle_jump(data, &mut update);
|
||||||
|
if !ability_key_is_pressed(data, self.static_data.ability_key) {
|
||||||
|
handle_interrupt(data, &mut update, true);
|
||||||
|
match update.character {
|
||||||
|
CharacterState::LeapMelee(_) => {},
|
||||||
|
_ => {
|
||||||
|
return update;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
match self.stage_section {
|
match self.stage_section {
|
||||||
// Delay before leaping into the air
|
// Delay before leaping into the air
|
||||||
|
@ -28,6 +28,8 @@ pub struct StaticData {
|
|||||||
pub projectile_light: Option<LightEmitter>,
|
pub projectile_light: Option<LightEmitter>,
|
||||||
pub projectile_gravity: Option<Gravity>,
|
pub projectile_gravity: Option<Gravity>,
|
||||||
pub projectile_speed: f32,
|
pub projectile_speed: f32,
|
||||||
|
/// What key is used to press ability
|
||||||
|
pub ability_key: AbilityKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -49,6 +51,15 @@ impl CharacterBehavior for Data {
|
|||||||
|
|
||||||
handle_move(data, &mut update, 1.0);
|
handle_move(data, &mut update, 1.0);
|
||||||
handle_jump(data, &mut update);
|
handle_jump(data, &mut update);
|
||||||
|
if !ability_key_is_pressed(data, self.static_data.ability_key) {
|
||||||
|
handle_interrupt(data, &mut update, true);
|
||||||
|
match update.character {
|
||||||
|
CharacterState::RepeaterRanged(_) => {},
|
||||||
|
_ => {
|
||||||
|
return update;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
match self.stage_section {
|
match self.stage_section {
|
||||||
StageSection::Movement => {
|
StageSection::Movement => {
|
||||||
|
@ -33,6 +33,8 @@ pub struct StaticData {
|
|||||||
pub requires_ground: bool,
|
pub requires_ground: bool,
|
||||||
/// Movement speed efficiency
|
/// Movement speed efficiency
|
||||||
pub move_efficiency: f32,
|
pub move_efficiency: f32,
|
||||||
|
/// What key is used to press ability
|
||||||
|
pub ability_key: AbilityKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -51,6 +53,15 @@ impl CharacterBehavior for Data {
|
|||||||
let mut update = StateUpdate::from(data);
|
let mut update = StateUpdate::from(data);
|
||||||
|
|
||||||
handle_move(data, &mut update, self.static_data.move_efficiency);
|
handle_move(data, &mut update, self.static_data.move_efficiency);
|
||||||
|
if !ability_key_is_pressed(data, self.static_data.ability_key) {
|
||||||
|
handle_interrupt(data, &mut update, true);
|
||||||
|
match update.character {
|
||||||
|
CharacterState::Shockwave(_) => {},
|
||||||
|
_ => {
|
||||||
|
return update;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
match self.stage_section {
|
match self.stage_section {
|
||||||
StageSection::Buildup => {
|
StageSection::Buildup => {
|
||||||
|
@ -71,11 +71,8 @@ impl CharacterBehavior for Data {
|
|||||||
Vec3::new(0.0, 0.0, update.vel.0.z + delta_vel_z) + data.inputs.move_dir * 5.0;
|
Vec3::new(0.0, 0.0, update.vel.0.z + delta_vel_z) + data.inputs.move_dir * 5.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allows for other states to interrupt this state
|
if !ability_key_is_pressed(data, self.static_data.ability_key) {
|
||||||
if self.static_data.is_interruptible
|
handle_interrupt(data, &mut update, !self.static_data.is_interruptible);
|
||||||
&& !ability_key_is_pressed(data, self.static_data.ability_key)
|
|
||||||
{
|
|
||||||
handle_interrupt(data, &mut update);
|
|
||||||
match update.character {
|
match update.character {
|
||||||
CharacterState::SpinMelee(_) => {},
|
CharacterState::SpinMelee(_) => {},
|
||||||
_ => {
|
_ => {
|
||||||
|
@ -420,10 +420,12 @@ pub fn unwrap_tool_data<'a>(data: &'a JoinData) -> Option<&'a Tool> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_interrupt(data: &JoinData, update: &mut StateUpdate) {
|
pub fn handle_interrupt(data: &JoinData, update: &mut StateUpdate, only_dodge: bool) {
|
||||||
|
if !only_dodge {
|
||||||
handle_ability1_input(data, update);
|
handle_ability1_input(data, update);
|
||||||
handle_ability2_input(data, update);
|
handle_ability2_input(data, update);
|
||||||
handle_ability3_input(data, update);
|
handle_ability3_input(data, update);
|
||||||
|
}
|
||||||
handle_dodge_input(data, update);
|
handle_dodge_input(data, update);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user