mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Changed roll movement.
This commit is contained in:
parent
55e75adec0
commit
860c766d62
@ -223,7 +223,7 @@ impl CharacterAbility {
|
||||
/// applicable.
|
||||
pub fn requirements_paid(&self, data: &JoinData, update: &mut StateUpdate) -> bool {
|
||||
match self {
|
||||
CharacterAbility::Roll {energy_cost, .. } => {
|
||||
CharacterAbility::Roll { energy_cost, .. } => {
|
||||
data.physics.on_ground
|
||||
&& data.vel.0.xy().magnitude_squared() > 0.5
|
||||
&& update
|
||||
@ -316,7 +316,7 @@ fn get_roll() -> CharacterAbility {
|
||||
buildup_duration: Duration::from_millis(100),
|
||||
movement_duration: Duration::from_millis(250),
|
||||
recover_duration: Duration::from_millis(150),
|
||||
roll_strength: 1.0,
|
||||
roll_strength: 2.5,
|
||||
buildup_iframes: true,
|
||||
movement_iframes: true,
|
||||
recover_iframes: false,
|
||||
|
@ -145,7 +145,7 @@ impl LoadoutBuilder {
|
||||
};
|
||||
|
||||
let active_item = if let Some(ItemKind::Tool(_)) = main_tool.as_ref().map(|i| i.kind()) {
|
||||
main_tool.map(|item| ItemConfig::from(item))
|
||||
main_tool.map(ItemConfig::from)
|
||||
} else {
|
||||
Some(ItemConfig {
|
||||
// We need the empty item so npcs can attack
|
||||
|
@ -2,13 +2,9 @@ use crate::{
|
||||
comp::{CharacterState, StateUpdate},
|
||||
states::utils::*,
|
||||
sys::character_behavior::{CharacterBehavior, JoinData},
|
||||
util::Dir,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::time::Duration;
|
||||
use vek::Vec3;
|
||||
|
||||
const ROLL_SPEED: f32 = 25.0;
|
||||
|
||||
/// Separated out to condense update portions of character state
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
@ -48,19 +44,12 @@ impl CharacterBehavior for Data {
|
||||
fn behavior(&self, data: &JoinData) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
|
||||
// Update velocity
|
||||
update.vel.0 = Vec3::new(0.0, 0.0, update.vel.0.z)
|
||||
+ (update.vel.0 * Vec3::new(1.0, 1.0, 0.0)
|
||||
+ 0.25 * data.inputs.move_dir.try_normalized().unwrap_or_default())
|
||||
.try_normalized()
|
||||
.unwrap_or_default()
|
||||
* ROLL_SPEED;
|
||||
|
||||
// Smooth orientation
|
||||
update.ori.0 = Dir::slerp_to_vec3(update.ori.0, update.vel.0.xy().into(), 9.0 * data.dt.0);
|
||||
handle_orientation(data, &mut update, 1.0);
|
||||
|
||||
match self.stage_section {
|
||||
StageSection::Buildup => {
|
||||
handle_move(data, &mut update, 1.0);
|
||||
if self.timer < self.static_data.buildup_duration {
|
||||
// Build up
|
||||
update.character = CharacterState::Roll(Data {
|
||||
@ -80,6 +69,16 @@ impl CharacterBehavior for Data {
|
||||
}
|
||||
},
|
||||
StageSection::Movement => {
|
||||
// Update velocity
|
||||
handle_forced_movement(
|
||||
data,
|
||||
&mut update,
|
||||
ForcedMovement::Forward {
|
||||
strength: self.static_data.roll_strength,
|
||||
},
|
||||
0.0,
|
||||
);
|
||||
|
||||
if self.timer < self.static_data.movement_duration {
|
||||
// Movement
|
||||
update.character = CharacterState::Roll(Data {
|
||||
@ -123,6 +122,8 @@ impl CharacterBehavior for Data {
|
||||
// If it somehow ends up in an incorrect stage section
|
||||
if self.was_wielded {
|
||||
update.character = CharacterState::Wielding;
|
||||
} else if self.was_sneak {
|
||||
update.character = CharacterState::Sneak;
|
||||
} else {
|
||||
update.character = CharacterState::Idle;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user