mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Various things can cause one to naturally leave a stance. Also mildly buffed cultists.
This commit is contained in:
parent
3caa9dc529
commit
c9db227e43
@ -17,6 +17,9 @@
|
||||
(1, Item("common.items.weapons.sceptre.sceptre_velorite_0")),
|
||||
]), None)),
|
||||
)),
|
||||
items: [
|
||||
(5, "common.items.consumable.potion_big"),
|
||||
],
|
||||
),
|
||||
meta: [
|
||||
SkillSetAsset("common.skillset.preset.rank5.fullskill"),
|
||||
|
@ -5,6 +5,7 @@ use crate::{
|
||||
Density, Energy, InputAttr, InputKind, Ori, Pos, Vel,
|
||||
},
|
||||
event::{LocalEvent, ServerEvent},
|
||||
resources::Time,
|
||||
states::{
|
||||
self,
|
||||
behavior::{CharacterBehavior, JoinData},
|
||||
@ -201,7 +202,8 @@ impl CharacterState {
|
||||
self,
|
||||
CharacterState::Idle(idle::Data {
|
||||
is_sneaking: true,
|
||||
footwear: _
|
||||
footwear: _,
|
||||
time_entered: _,
|
||||
}) | CharacterState::Wielding(wielding::Data {
|
||||
is_sneaking: true,
|
||||
..
|
||||
@ -926,6 +928,11 @@ impl CharacterState {
|
||||
CharacterState::DiveMelee(_) => Some(AttackSource::Melee),
|
||||
CharacterState::RiposteMelee(_) => Some(AttackSource::Melee),
|
||||
CharacterState::RapidMelee(_) => Some(AttackSource::Melee),
|
||||
CharacterState::LeapShockwave(data) => Some(if data.static_data.requires_ground {
|
||||
AttackSource::GroundShockwave
|
||||
} else {
|
||||
AttackSource::AirShockwave
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -967,6 +974,7 @@ impl Default for CharacterState {
|
||||
Self::Idle(idle::Data {
|
||||
is_sneaking: false,
|
||||
footwear: None,
|
||||
time_entered: Time(0.0),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -790,6 +790,9 @@ impl ProjectileConstructor {
|
||||
Snowball { .. } => true,
|
||||
ExplodingPumpkin { .. } => true,
|
||||
DagonBomb { .. } => true,
|
||||
SeaBomb { .. } => true,
|
||||
WindBomb { .. } => true,
|
||||
IceBomb { .. } => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ impl CharacterBehavior for Data {
|
||||
fn behavior(&self, data: &JoinData, output_events: &mut OutputEvents) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
|
||||
leave_stance(data, output_events);
|
||||
handle_wield(data, &mut update);
|
||||
handle_jump(data, output_events, &mut update, 1.0);
|
||||
|
||||
|
@ -40,6 +40,7 @@ impl CharacterBehavior for Data {
|
||||
fn behavior(&self, data: &JoinData, output_events: &mut OutputEvents) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
|
||||
leave_stance(data, output_events);
|
||||
handle_orientation(data, &mut update, 1.0, None);
|
||||
handle_move(data, &mut update, 1.0);
|
||||
handle_jump(data, output_events, &mut update, 1.0);
|
||||
|
@ -4,13 +4,15 @@ use crate::{
|
||||
character_state::OutputEvents, controller::InputKind, inventory::item::armor::Friction,
|
||||
CharacterState, InventoryAction, StateUpdate,
|
||||
},
|
||||
resources::Time,
|
||||
states::behavior::{CharacterBehavior, JoinData},
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Default)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Default)]
|
||||
pub struct Data {
|
||||
pub is_sneaking: bool,
|
||||
pub(crate) time_entered: Time,
|
||||
// None means unknown
|
||||
pub(crate) footwear: Option<Friction>,
|
||||
}
|
||||
@ -19,6 +21,11 @@ impl CharacterBehavior for Data {
|
||||
fn behavior(&self, data: &JoinData, output_events: &mut OutputEvents) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
|
||||
const LEAVE_STANCE_DELAY: f64 = 5.0;
|
||||
if (self.time_entered.0 + LEAVE_STANCE_DELAY) < data.time.0 {
|
||||
leave_stance(data, output_events);
|
||||
}
|
||||
|
||||
handle_skating(data, &mut update);
|
||||
handle_orientation(data, &mut update, 1.0, None);
|
||||
handle_move(data, &mut update, if self.is_sneaking { 0.4 } else { 1.0 });
|
||||
@ -36,6 +43,7 @@ impl CharacterBehavior for Data {
|
||||
{
|
||||
update.character = CharacterState::Idle(Data {
|
||||
is_sneaking: false,
|
||||
time_entered: self.time_entered,
|
||||
footwear: self.footwear,
|
||||
});
|
||||
}
|
||||
@ -88,6 +96,7 @@ impl CharacterBehavior for Data {
|
||||
let mut update = StateUpdate::from(data);
|
||||
update.character = CharacterState::Idle(Data {
|
||||
is_sneaking: true,
|
||||
time_entered: self.time_entered,
|
||||
footwear: self.footwear,
|
||||
});
|
||||
update
|
||||
|
@ -36,6 +36,7 @@ impl CharacterBehavior for Data {
|
||||
fn behavior(&self, data: &JoinData, output_events: &mut OutputEvents) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
|
||||
leave_stance(data, output_events);
|
||||
handle_orientation(data, &mut update, self.static_data.ori_modifier, None);
|
||||
handle_move(data, &mut update, 0.7);
|
||||
handle_jump(data, output_events, &mut update, 1.0);
|
||||
@ -70,7 +71,9 @@ impl CharacterBehavior for Data {
|
||||
}
|
||||
|
||||
// At end of state logic so an interrupt isn't overwritten
|
||||
if !input_is_pressed(data, self.static_data.ability_info.input) && input_is_pressed(data, InputKind::Roll) {
|
||||
if !input_is_pressed(data, self.static_data.ability_info.input)
|
||||
&& input_is_pressed(data, InputKind::Roll)
|
||||
{
|
||||
handle_input(data, output_events, &mut update, InputKind::Roll);
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,6 @@
|
||||
use super::utils::*;
|
||||
use crate::{
|
||||
comp::{
|
||||
ability::Stance, character_state::OutputEvents, CharacterState, InventoryAction,
|
||||
StateUpdate,
|
||||
},
|
||||
event::ServerEvent,
|
||||
comp::{character_state::OutputEvents, CharacterState, InventoryAction, StateUpdate},
|
||||
states::{
|
||||
behavior::{CharacterBehavior, JoinData},
|
||||
idle,
|
||||
@ -19,13 +15,7 @@ impl CharacterBehavior for Data {
|
||||
fn behavior(&self, data: &JoinData, output_events: &mut OutputEvents) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
|
||||
if !matches!(data.stance, Some(Stance::None)) {
|
||||
output_events.emit_server(ServerEvent::ChangeStance {
|
||||
entity: data.entity,
|
||||
stance: Stance::None,
|
||||
});
|
||||
}
|
||||
|
||||
leave_stance(data, output_events);
|
||||
handle_wield(data, &mut update);
|
||||
handle_jump(data, output_events, &mut update, 1.0);
|
||||
|
||||
|
@ -35,12 +35,14 @@ impl CharacterBehavior for Data {
|
||||
fn behavior(&self, data: &JoinData, output_events: &mut OutputEvents) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
|
||||
leave_stance(data, output_events);
|
||||
handle_wield(data, &mut update);
|
||||
handle_jump(data, output_events, &mut update, 1.0);
|
||||
|
||||
if !data.physics.skating_active {
|
||||
update.character = CharacterState::Idle(idle::Data {
|
||||
is_sneaking: false,
|
||||
time_entered: *data.time,
|
||||
footwear: Some(self.footwear),
|
||||
});
|
||||
} else {
|
||||
|
@ -56,6 +56,8 @@ impl CharacterBehavior for Data {
|
||||
fn behavior(&self, data: &JoinData, output_events: &mut OutputEvents) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
|
||||
leave_stance(data, output_events);
|
||||
|
||||
let ori_dir = Dir::from_unnormalized(Vec3::from(
|
||||
(self.static_data.sprite_pos.map(|x| x as f32 + 0.5) - data.pos.0).xy(),
|
||||
));
|
||||
|
@ -15,7 +15,6 @@ pub struct StaticData {
|
||||
pub recover_duration: Duration,
|
||||
/// Fraction of normal movement speed allowed during the state
|
||||
pub movement_speed: f32,
|
||||
/// Poise state (used for determining animation in the client)
|
||||
pub poise_state: PoiseState,
|
||||
}
|
||||
|
||||
@ -33,9 +32,16 @@ pub struct Data {
|
||||
}
|
||||
|
||||
impl CharacterBehavior for Data {
|
||||
fn behavior(&self, data: &JoinData, _: &mut OutputEvents) -> StateUpdate {
|
||||
fn behavior(&self, data: &JoinData, output_events: &mut OutputEvents) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
|
||||
if matches!(
|
||||
self.static_data.poise_state,
|
||||
PoiseState::Stunned | PoiseState::Dazed | PoiseState::KnockedDown
|
||||
) {
|
||||
leave_stance(data, output_events);
|
||||
}
|
||||
|
||||
handle_orientation(data, &mut update, 1.0, None);
|
||||
handle_move(data, &mut update, self.static_data.movement_speed);
|
||||
|
||||
|
@ -14,9 +14,10 @@ const TURN_RATE: f32 = 40.0;
|
||||
pub struct Data;
|
||||
|
||||
impl CharacterBehavior for Data {
|
||||
fn behavior(&self, data: &JoinData, _: &mut OutputEvents) -> StateUpdate {
|
||||
fn behavior(&self, data: &JoinData, output_events: &mut OutputEvents) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
|
||||
leave_stance(data, output_events);
|
||||
handle_wield(data, &mut update);
|
||||
handle_orientation(data, &mut update, TURN_RATE, None);
|
||||
|
||||
|
@ -52,6 +52,8 @@ impl CharacterBehavior for Data {
|
||||
fn behavior(&self, data: &JoinData, output_events: &mut OutputEvents) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
|
||||
leave_stance(data, output_events);
|
||||
|
||||
match self.static_data.item_kind {
|
||||
ItemUseKind::Consumable(ConsumableKind::Drink) => {
|
||||
handle_orientation(data, &mut update, 1.0, None);
|
||||
|
@ -2,7 +2,7 @@ use crate::{
|
||||
astar::Astar,
|
||||
combat,
|
||||
comp::{
|
||||
ability::{Ability, AbilityInitEvent, AbilityInput, AbilityMeta, Capability},
|
||||
ability::{Ability, AbilityInitEvent, AbilityInput, AbilityMeta, Capability, Stance},
|
||||
arthropod, biped_large, biped_small, bird_medium,
|
||||
character_state::OutputEvents,
|
||||
controller::InventoryManip,
|
||||
@ -323,6 +323,7 @@ impl Body {
|
||||
pub fn handle_skating(data: &JoinData, update: &mut StateUpdate) {
|
||||
if let Idle(idle::Data {
|
||||
is_sneaking,
|
||||
time_entered,
|
||||
mut footwear,
|
||||
}) = data.character
|
||||
{
|
||||
@ -336,6 +337,7 @@ pub fn handle_skating(data: &JoinData, update: &mut StateUpdate) {
|
||||
});
|
||||
update.character = Idle(idle::Data {
|
||||
is_sneaking: *is_sneaking,
|
||||
time_entered: *time_entered,
|
||||
footwear,
|
||||
});
|
||||
}
|
||||
@ -770,6 +772,7 @@ pub fn attempt_sneak(data: &JoinData<'_>, update: &mut StateUpdate) {
|
||||
if data.physics.on_ground.is_some() && data.body.is_humanoid() {
|
||||
update.character = Idle(idle::Data {
|
||||
is_sneaking: true,
|
||||
time_entered: *data.time,
|
||||
footwear: data.character.footwear(),
|
||||
});
|
||||
}
|
||||
@ -1361,7 +1364,17 @@ impl Mul<f32> for ForcedMovement {
|
||||
Sideways(x) => Sideways(x * scalar),
|
||||
DirectedReverse(x) => DirectedReverse(x * scalar),
|
||||
AntiDirectedForward(x) => AntiDirectedForward(x * scalar),
|
||||
Leap { vertical, forward, progress, direction } => Leap { vertical: vertical * scalar, forward: forward * scalar, progress, direction },
|
||||
Leap {
|
||||
vertical,
|
||||
forward,
|
||||
progress,
|
||||
direction,
|
||||
} => Leap {
|
||||
vertical: vertical * scalar,
|
||||
forward: forward * scalar,
|
||||
progress,
|
||||
direction,
|
||||
},
|
||||
Hover { move_input } => Hover { move_input },
|
||||
}
|
||||
}
|
||||
@ -1447,6 +1460,7 @@ pub fn end_ability(data: &JoinData<'_>, update: &mut StateUpdate) {
|
||||
update.character = CharacterState::Idle(idle::Data {
|
||||
is_sneaking: data.character.is_stealthy(),
|
||||
footwear: None,
|
||||
time_entered: *data.time,
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1477,3 +1491,12 @@ impl HandInfo {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn leave_stance(data: &JoinData<'_>, output_events: &mut OutputEvents) {
|
||||
if !matches!(data.stance, Some(Stance::None)) {
|
||||
output_events.emit_server(ServerEvent::ChangeStance {
|
||||
entity: data.entity,
|
||||
stance: Stance::None,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -63,6 +63,7 @@ impl CharacterBehavior for Data {
|
||||
if reset_to_idle {
|
||||
update.character = CharacterState::Idle(idle::Data {
|
||||
is_sneaking: data.character.is_stealthy(),
|
||||
time_entered: *data.time,
|
||||
footwear: None,
|
||||
});
|
||||
}
|
||||
@ -80,6 +81,7 @@ impl CharacterBehavior for Data {
|
||||
let mut update = StateUpdate::from(data);
|
||||
update.character = CharacterState::Idle(idle::Data {
|
||||
is_sneaking: self.is_sneaking,
|
||||
time_entered: *data.time,
|
||||
footwear: None,
|
||||
});
|
||||
update
|
||||
|
Loading…
Reference in New Issue
Block a user