mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'sam/interrupting-rolls' into 'master'
Rolling can now interrupt any attack. See merge request veloren/veloren!1537
This commit is contained in:
commit
435d354dad
@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Campfire SFX
|
||||
- Wind SFX system
|
||||
- Added Norwegian language
|
||||
- Roll can now interrupt attacks
|
||||
|
||||
### Changed
|
||||
|
||||
|
@ -589,6 +589,7 @@ impl From<(&CharacterAbility, AbilityKey)> for CharacterState {
|
||||
knockback: *knockback,
|
||||
range: *range,
|
||||
max_angle: *max_angle,
|
||||
ability_key: key,
|
||||
},
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Buildup,
|
||||
@ -741,6 +742,7 @@ impl From<(&CharacterAbility, AbilityKey)> for CharacterState {
|
||||
max_angle: *max_angle,
|
||||
forward_leap_strength: *forward_leap_strength,
|
||||
vertical_leap_strength: *vertical_leap_strength,
|
||||
ability_key: key,
|
||||
},
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Buildup,
|
||||
@ -877,6 +879,7 @@ impl From<(&CharacterAbility, AbilityKey)> for CharacterState {
|
||||
projectile_light: *projectile_light,
|
||||
projectile_gravity: *projectile_gravity,
|
||||
projectile_speed: *projectile_speed,
|
||||
ability_key: key,
|
||||
},
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Movement,
|
||||
@ -908,6 +911,7 @@ impl From<(&CharacterAbility, AbilityKey)> for CharacterState {
|
||||
shockwave_duration: Duration::from_millis(*shockwave_duration),
|
||||
requires_ground: *requires_ground,
|
||||
move_efficiency: *move_efficiency,
|
||||
ability_key: key,
|
||||
},
|
||||
timer: Duration::default(),
|
||||
stage_section: StageSection::Buildup,
|
||||
|
@ -63,6 +63,15 @@ impl CharacterBehavior for Data {
|
||||
|
||||
handle_move(data, &mut update, 0.4);
|
||||
handle_jump(data, &mut update);
|
||||
if !ability_key_is_pressed(data, self.static_data.ability_key) {
|
||||
handle_interrupt(data, &mut update, false);
|
||||
match update.character {
|
||||
CharacterState::BasicBeam(_) => {},
|
||||
_ => {
|
||||
return update;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
if unwrap_tool_data(data).is_none() {
|
||||
update.character = CharacterState::Idle;
|
||||
|
@ -24,6 +24,8 @@ pub struct StaticData {
|
||||
pub range: f32,
|
||||
/// Max angle (45.0 will give you a 90.0 angle window)
|
||||
pub max_angle: f32,
|
||||
/// What key is used to press ability
|
||||
pub ability_key: AbilityKey,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
@ -45,6 +47,15 @@ impl CharacterBehavior for Data {
|
||||
|
||||
handle_move(data, &mut update, 0.7);
|
||||
handle_jump(data, &mut update);
|
||||
if !ability_key_is_pressed(data, self.static_data.ability_key) {
|
||||
handle_interrupt(data, &mut update, false);
|
||||
match update.character {
|
||||
CharacterState::BasicMelee(_) => {},
|
||||
_ => {
|
||||
return update;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
match self.stage_section {
|
||||
StageSection::Buildup => {
|
||||
|
@ -48,6 +48,15 @@ impl CharacterBehavior for Data {
|
||||
|
||||
handle_move(data, &mut update, 0.3);
|
||||
handle_jump(data, &mut update);
|
||||
if !ability_key_is_pressed(data, self.static_data.ability_key) {
|
||||
handle_interrupt(data, &mut update, false);
|
||||
match update.character {
|
||||
CharacterState::BasicRanged(_) => {},
|
||||
_ => {
|
||||
return update;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
match self.stage_section {
|
||||
StageSection::Buildup => {
|
||||
|
@ -59,6 +59,15 @@ impl CharacterBehavior for Data {
|
||||
|
||||
handle_move(data, &mut update, 0.7);
|
||||
handle_jump(data, &mut update);
|
||||
if !ability_key_is_pressed(data, self.static_data.ability_key) {
|
||||
handle_interrupt(data, &mut update, false);
|
||||
match update.character {
|
||||
CharacterState::ChargedMelee(_) => {},
|
||||
_ => {
|
||||
return update;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
match self.stage_section {
|
||||
StageSection::Charge => {
|
||||
|
@ -63,6 +63,15 @@ impl CharacterBehavior for Data {
|
||||
|
||||
handle_move(data, &mut update, 0.3);
|
||||
handle_jump(data, &mut update);
|
||||
if !ability_key_is_pressed(data, self.static_data.ability_key) {
|
||||
handle_interrupt(data, &mut update, false);
|
||||
match update.character {
|
||||
CharacterState::ChargedRanged(_) => {},
|
||||
_ => {
|
||||
return update;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
match self.stage_section {
|
||||
StageSection::Buildup => {
|
||||
|
@ -110,20 +110,11 @@ impl CharacterBehavior for Data {
|
||||
|
||||
handle_orientation(data, &mut update, 1.0);
|
||||
handle_move(data, &mut update, 0.3);
|
||||
|
||||
let stage_index = (self.stage - 1) as usize;
|
||||
|
||||
// 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 !ability_key_is_pressed(data, self.static_data.ability_key) {
|
||||
handle_interrupt(data, &mut update, self.static_data.is_interruptible);
|
||||
if let CharacterState::Roll(roll) = &mut update.character {
|
||||
roll.was_combo = Some((self.stage, self.combo));
|
||||
}
|
||||
}
|
||||
match update.character {
|
||||
CharacterState::ComboMelee(_) => {},
|
||||
_ => {
|
||||
@ -132,6 +123,8 @@ impl CharacterBehavior for Data {
|
||||
}
|
||||
}
|
||||
|
||||
let stage_index = (self.stage - 1) as usize;
|
||||
|
||||
let speed_modifer = 1.0
|
||||
+ self.static_data.max_speed_increase
|
||||
* (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_move(data, &mut update, 0.1);
|
||||
|
||||
// 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, self.static_data.ability_key) {
|
||||
handle_interrupt(data, &mut update, self.static_data.is_interruptible);
|
||||
match update.character {
|
||||
CharacterState::DashMelee(_) => {},
|
||||
_ => {
|
||||
|
@ -30,6 +30,8 @@ pub struct StaticData {
|
||||
pub forward_leap_strength: f32,
|
||||
/// Affects how high the player leaps
|
||||
pub vertical_leap_strength: f32,
|
||||
/// What key is used to press ability
|
||||
pub ability_key: AbilityKey,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
@ -51,6 +53,15 @@ impl CharacterBehavior for Data {
|
||||
|
||||
handle_move(data, &mut update, 0.3);
|
||||
handle_jump(data, &mut update);
|
||||
if !ability_key_is_pressed(data, self.static_data.ability_key) {
|
||||
handle_interrupt(data, &mut update, false);
|
||||
match update.character {
|
||||
CharacterState::LeapMelee(_) => {},
|
||||
_ => {
|
||||
return update;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
match self.stage_section {
|
||||
// Delay before leaping into the air
|
||||
|
@ -28,6 +28,8 @@ pub struct StaticData {
|
||||
pub projectile_light: Option<LightEmitter>,
|
||||
pub projectile_gravity: Option<Gravity>,
|
||||
pub projectile_speed: f32,
|
||||
/// What key is used to press ability
|
||||
pub ability_key: AbilityKey,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
@ -49,6 +51,15 @@ impl CharacterBehavior for Data {
|
||||
|
||||
handle_move(data, &mut update, 1.0);
|
||||
handle_jump(data, &mut update);
|
||||
if !ability_key_is_pressed(data, self.static_data.ability_key) {
|
||||
handle_interrupt(data, &mut update, false);
|
||||
match update.character {
|
||||
CharacterState::RepeaterRanged(_) => {},
|
||||
_ => {
|
||||
return update;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
match self.stage_section {
|
||||
StageSection::Movement => {
|
||||
|
@ -33,6 +33,8 @@ pub struct StaticData {
|
||||
pub requires_ground: bool,
|
||||
/// Movement speed efficiency
|
||||
pub move_efficiency: f32,
|
||||
/// What key is used to press ability
|
||||
pub ability_key: AbilityKey,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
@ -51,6 +53,15 @@ impl CharacterBehavior for Data {
|
||||
let mut update = StateUpdate::from(data);
|
||||
|
||||
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, false);
|
||||
match update.character {
|
||||
CharacterState::Shockwave(_) => {},
|
||||
_ => {
|
||||
return update;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
match self.stage_section {
|
||||
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;
|
||||
}
|
||||
|
||||
// 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, self.static_data.ability_key) {
|
||||
handle_interrupt(data, &mut update, self.static_data.is_interruptible);
|
||||
match update.character {
|
||||
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, attacks_interrupt: bool) {
|
||||
if attacks_interrupt {
|
||||
handle_ability1_input(data, update);
|
||||
handle_ability2_input(data, update);
|
||||
handle_ability3_input(data, update);
|
||||
}
|
||||
handle_dodge_input(data, update);
|
||||
}
|
||||
|
||||
|
@ -86,6 +86,7 @@ fn maps_basic_melee() {
|
||||
knockback: 0.0,
|
||||
range: 1.0,
|
||||
max_angle: 1.0,
|
||||
ability_key: states::utils::AbilityKey::Mouse1,
|
||||
},
|
||||
timer: Duration::default(),
|
||||
stage_section: states::utils::StageSection::Buildup,
|
||||
|
Loading…
Reference in New Issue
Block a user