mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Better climbing, fireball impl
This commit is contained in:
parent
ea2500e7ab
commit
58585e0810
@ -17,12 +17,7 @@ pub enum CharacterAbility {
|
||||
max_angle: f32,
|
||||
},
|
||||
BasicRanged {
|
||||
prepare_duration: Duration,
|
||||
recover_duration: Duration,
|
||||
projectile: Projectile,
|
||||
projectile_body: Body,
|
||||
},
|
||||
CastFireball {
|
||||
energy_cost: u32,
|
||||
prepare_duration: Duration,
|
||||
recover_duration: Duration,
|
||||
projectile: Projectile,
|
||||
@ -70,11 +65,11 @@ impl CharacterAbility {
|
||||
.try_change_by(-300, EnergySource::Ability)
|
||||
.is_ok()
|
||||
},
|
||||
CharacterAbility::CastFireball { .. } => {
|
||||
CharacterAbility::BasicRanged { energy_cost, .. } => {
|
||||
!data.physics.in_fluid
|
||||
&& update
|
||||
.energy
|
||||
.try_change_by(-500, EnergySource::Ability)
|
||||
.try_change_by(-(*energy_cost as i32), EnergySource::Ability)
|
||||
.is_ok()
|
||||
},
|
||||
_ => true,
|
||||
@ -127,6 +122,7 @@ impl From<&CharacterAbility> for CharacterState {
|
||||
recover_duration,
|
||||
projectile,
|
||||
projectile_body,
|
||||
energy_cost: _,
|
||||
} => CharacterState::BasicRanged(basic_ranged::Data {
|
||||
exhausted: false,
|
||||
prepare_timer: Duration::default(),
|
||||
@ -135,18 +131,6 @@ impl From<&CharacterAbility> for CharacterState {
|
||||
projectile: projectile.clone(),
|
||||
projectile_body: *projectile_body,
|
||||
}),
|
||||
CharacterAbility::CastFireball {
|
||||
prepare_duration,
|
||||
recover_duration,
|
||||
projectile,
|
||||
projectile_body,
|
||||
} => CharacterState::CastFireball(cast_fireball::Data {
|
||||
exhausted: false,
|
||||
prepare_duration: *prepare_duration,
|
||||
recover_duration: *recover_duration,
|
||||
projectile: projectile.clone(),
|
||||
projectile_body: *projectile_body,
|
||||
}),
|
||||
CharacterAbility::Boost { duration, only_up } => CharacterState::Boost(boost::Data {
|
||||
duration: *duration,
|
||||
only_up: *only_up,
|
||||
|
@ -52,8 +52,6 @@ pub enum CharacterState {
|
||||
BasicMelee(basic_melee::Data),
|
||||
/// A basic ranged attack (e.g. bow)
|
||||
BasicRanged(basic_ranged::Data),
|
||||
/// Cast a fireball
|
||||
CastFireball(cast_fireball::Data),
|
||||
/// A force will boost you into a direction for some duration
|
||||
Boost(boost::Data),
|
||||
/// Dash forward and then attack
|
||||
@ -72,7 +70,6 @@ impl CharacterState {
|
||||
CharacterState::Wielding
|
||||
| CharacterState::BasicMelee(_)
|
||||
| CharacterState::BasicRanged(_)
|
||||
| CharacterState::CastFireball(_)
|
||||
| CharacterState::DashMelee(_)
|
||||
| CharacterState::TripleStrike(_)
|
||||
| CharacterState::TimedCombo(_)
|
||||
@ -92,7 +89,6 @@ impl CharacterState {
|
||||
match self {
|
||||
CharacterState::BasicMelee(_)
|
||||
| CharacterState::BasicRanged(_)
|
||||
| CharacterState::CastFireball(_)
|
||||
| CharacterState::TimedCombo(_)
|
||||
| CharacterState::DashMelee(_)
|
||||
| CharacterState::TripleStrike(_) => true,
|
||||
|
@ -89,6 +89,7 @@ impl ToolData {
|
||||
max_angle: 60.0,
|
||||
}],
|
||||
Bow(_) => vec![BasicRanged {
|
||||
energy_cost: 0,
|
||||
prepare_duration: Duration::from_millis(100),
|
||||
recover_duration: Duration::from_millis(300),
|
||||
projectile: Projectile {
|
||||
@ -127,6 +128,7 @@ impl ToolData {
|
||||
max_angle: 45.0,
|
||||
},
|
||||
BasicRanged {
|
||||
energy_cost: 0,
|
||||
prepare_duration: Duration::from_millis(300),
|
||||
recover_duration: Duration::from_millis(100),
|
||||
projectile: Projectile {
|
||||
@ -145,7 +147,8 @@ impl ToolData {
|
||||
},
|
||||
projectile_body: Body::Object(object::Body::BoltFire),
|
||||
},
|
||||
CastFireball {
|
||||
BasicRanged {
|
||||
energy_cost: 400,
|
||||
prepare_duration: Duration::from_millis(800),
|
||||
recover_duration: Duration::from_millis(300),
|
||||
projectile: Projectile {
|
||||
@ -180,6 +183,7 @@ impl ToolData {
|
||||
},
|
||||
],
|
||||
Possess => vec![BasicRanged {
|
||||
energy_cost: 0,
|
||||
prepare_duration: Duration::from_millis(300),
|
||||
recover_duration: Duration::from_millis(300),
|
||||
projectile: Projectile {
|
||||
|
@ -1,85 +0,0 @@
|
||||
use crate::{
|
||||
comp::{Body, CharacterState, LightEmitter, Projectile, StateUpdate},
|
||||
event::ServerEvent,
|
||||
states::utils::*,
|
||||
sys::character_behavior::*,
|
||||
};
|
||||
use std::time::Duration;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Data {
|
||||
/// How long we need to wait before we fire
|
||||
pub prepare_duration: Duration,
|
||||
/// How long the state has until exiting
|
||||
pub recover_duration: Duration,
|
||||
/// Projectile
|
||||
pub projectile: Projectile,
|
||||
/// Projectile
|
||||
pub projectile_body: Body,
|
||||
/// Whether the attack fired already
|
||||
pub exhausted: bool,
|
||||
}
|
||||
|
||||
impl CharacterBehavior for Data {
|
||||
fn behavior(&self, data: &JoinData) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
|
||||
handle_move(data, &mut update);
|
||||
handle_jump(data, &mut update);
|
||||
|
||||
if self.prepare_duration != Duration::default() {
|
||||
// Prepare
|
||||
update.character = CharacterState::CastFireball(Data {
|
||||
prepare_duration: self
|
||||
.prepare_duration
|
||||
.checked_sub(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
recover_duration: self.recover_duration,
|
||||
projectile: self.projectile.clone(),
|
||||
projectile_body: self.projectile_body,
|
||||
exhausted: false,
|
||||
});
|
||||
} else if !self.exhausted {
|
||||
// Fire
|
||||
let mut projectile = self.projectile.clone();
|
||||
projectile.set_owner(*data.uid);
|
||||
update.server_events.push_front(ServerEvent::Shoot {
|
||||
entity: data.entity,
|
||||
dir: data.inputs.look_dir,
|
||||
body: self.projectile_body,
|
||||
light: Some(LightEmitter {
|
||||
col: (0.72, 0.11, 0.11).into(),
|
||||
..Default::default()
|
||||
}),
|
||||
projectile,
|
||||
gravity: None,
|
||||
});
|
||||
|
||||
update.character = CharacterState::CastFireball(Data {
|
||||
prepare_duration: Duration::default(),
|
||||
recover_duration: self.recover_duration,
|
||||
projectile: self.projectile.clone(),
|
||||
projectile_body: self.projectile_body,
|
||||
exhausted: true,
|
||||
});
|
||||
} else if self.recover_duration != Duration::default() {
|
||||
// Recovery
|
||||
update.character = CharacterState::CastFireball(Data {
|
||||
prepare_duration: Duration::default(),
|
||||
recover_duration: self
|
||||
.recover_duration
|
||||
.checked_sub(Duration::from_secs_f32(data.dt.0))
|
||||
.unwrap_or_default(),
|
||||
projectile: self.projectile.clone(),
|
||||
projectile_body: self.projectile_body,
|
||||
exhausted: true,
|
||||
});
|
||||
return update;
|
||||
} else {
|
||||
// Done
|
||||
update.character = CharacterState::Wielding;
|
||||
}
|
||||
|
||||
update
|
||||
}
|
||||
}
|
@ -26,8 +26,11 @@ impl CharacterBehavior for Data {
|
||||
update.character = CharacterState::Idle {};
|
||||
}
|
||||
|
||||
// If no wall is in front of character ...
|
||||
if data.physics.on_wall.is_none() || data.physics.on_ground {
|
||||
// If no wall is in front of character or we stopped holding space:
|
||||
if data.physics.on_wall.is_none()
|
||||
|| data.physics.on_ground
|
||||
|| !data.inputs.jump.is_pressed()
|
||||
{
|
||||
if data.inputs.jump.is_pressed() {
|
||||
// They've climbed atop something, give them a boost
|
||||
update
|
||||
|
@ -2,7 +2,6 @@ pub mod basic_block;
|
||||
pub mod basic_melee;
|
||||
pub mod basic_ranged;
|
||||
pub mod boost;
|
||||
pub mod cast_fireball;
|
||||
pub mod climb;
|
||||
pub mod dash_melee;
|
||||
pub mod equipping;
|
||||
|
@ -183,7 +183,6 @@ impl<'a> System<'a> for Sys {
|
||||
CharacterState::TripleStrike(data) => data.behavior(&j),
|
||||
CharacterState::BasicMelee(data) => data.behavior(&j),
|
||||
CharacterState::BasicRanged(data) => data.behavior(&j),
|
||||
CharacterState::CastFireball(data) => data.behavior(&j),
|
||||
CharacterState::Boost(data) => data.behavior(&j),
|
||||
CharacterState::DashMelee(data) => data.behavior(&j),
|
||||
CharacterState::TimedCombo(data) => data.behavior(&j),
|
||||
|
@ -488,15 +488,6 @@ impl FigureMgr {
|
||||
skeleton_attr,
|
||||
)
|
||||
},
|
||||
CharacterState::CastFireball(_) => {
|
||||
anim::character::ShootAnimation::update_skeleton(
|
||||
&target_base,
|
||||
(active_tool_kind, time),
|
||||
state.state_time,
|
||||
&mut state_animation_rate,
|
||||
skeleton_attr,
|
||||
)
|
||||
},
|
||||
CharacterState::Boost(_) => {
|
||||
anim::character::AttackAnimation::update_skeleton(
|
||||
&target_base,
|
||||
|
Loading…
Reference in New Issue
Block a user