Merge branch 'scott-c/wield-changes' into 'master'

Scott c/wield changes

See merge request veloren/veloren!1072
This commit is contained in:
Imbris 2020-06-15 20:51:35 +00:00
commit c22f9530e4
6 changed files with 29 additions and 12 deletions

View File

@ -33,6 +33,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed a crash caused by certain audio devices on OSX - Fixed a crash caused by certain audio devices on OSX
- Bow animations now show held arrows - Bow animations now show held arrows
- Fixed a bug where walk/run sfx played while a character rolled/dodged - Fixed a bug where walk/run sfx played while a character rolled/dodged
- Energy regen resets on last ability use instead of on wield
- Fixed unable to use ability; Secondary and ability3 (fire rod) will now automatically wield
### Removed ### Removed

View File

@ -11,7 +11,7 @@ impl CharacterBehavior for Data {
fn behavior(&self, data: &JoinData) -> StateUpdate { fn behavior(&self, data: &JoinData) -> StateUpdate {
let mut update = StateUpdate::from(data); let mut update = StateUpdate::from(data);
handle_primary_wield(data, &mut update); handle_wield(data, &mut update);
// Try to Fall/Stand up/Move // Try to Fall/Stand up/Move
if !data.physics.on_ground || data.inputs.move_dir.magnitude_squared() > 0.0 { if !data.physics.on_ground || data.inputs.move_dir.magnitude_squared() > 0.0 {

View File

@ -12,7 +12,7 @@ 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);
handle_primary_wield(data, &mut update); handle_wield(data, &mut update);
handle_climb(data, &mut update); handle_climb(data, &mut update);
handle_glide(data, &mut update); handle_glide(data, &mut update);
handle_dodge_input(data, &mut update); handle_dodge_input(data, &mut update);

View File

@ -11,7 +11,7 @@ impl CharacterBehavior for Data {
fn behavior(&self, data: &JoinData) -> StateUpdate { fn behavior(&self, data: &JoinData) -> StateUpdate {
let mut update = StateUpdate::from(data); let mut update = StateUpdate::from(data);
handle_primary_wield(data, &mut update); handle_wield(data, &mut update);
// Try to Fall/Stand up/Move // Try to Fall/Stand up/Move
if !data.physics.on_ground || data.inputs.move_dir.magnitude_squared() > 0.0 { if !data.physics.on_ground || data.inputs.move_dir.magnitude_squared() > 0.0 {

View File

@ -96,10 +96,13 @@ fn swim_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) {
} }
} }
/// First checks whether `primary` input is pressed, then /// First checks whether `primary`, `secondary` or `ability3` input is pressed,
/// attempts to go into Equipping state, otherwise Idle /// then attempts to go into Equipping state, otherwise Idle
pub fn handle_primary_wield(data: &JoinData, update: &mut StateUpdate) { pub fn handle_wield(data: &JoinData, update: &mut StateUpdate) {
if data.inputs.primary.is_pressed() { if data.inputs.primary.is_pressed()
|| data.inputs.secondary.is_pressed()
|| data.inputs.ability3.is_pressed()
{
attempt_wield(data, update); attempt_wield(data, update);
} }
} }

View File

@ -75,9 +75,15 @@ impl<'a> System<'a> for Sys {
.set_to(stat.health.maximum(), HealthSource::LevelUp); .set_to(stat.health.maximum(), HealthSource::LevelUp);
} }
// Accelerate recharging energy if not wielding.
match character_state { match character_state {
CharacterState::Idle { .. } | CharacterState::Sit { .. } => { // Accelerate recharging energy.
CharacterState::Idle { .. }
| CharacterState::Sit { .. }
| CharacterState::Dance { .. }
| CharacterState::Glide { .. }
| CharacterState::Wielding { .. }
| CharacterState::Equipping { .. }
| CharacterState::Boost { .. } => {
let res = { let res = {
let energy = energy.get_unchecked(); let energy = energy.get_unchecked();
energy.current() < energy.maximum() energy.current() < energy.maximum()
@ -95,13 +101,19 @@ impl<'a> System<'a> for Sys {
(energy.regen_rate + ENERGY_REGEN_ACCEL * dt.0).min(100.0); (energy.regen_rate + ENERGY_REGEN_ACCEL * dt.0).min(100.0);
} }
}, },
// Wield does not regen and sets the rate back to zero. // Ability use does not regen and sets the rate back to zero.
CharacterState::Wielding { .. } => { CharacterState::BasicMelee { .. }
| CharacterState::DashMelee { .. }
| CharacterState::TripleStrike { .. }
| CharacterState::BasicRanged { .. }
| CharacterState::BasicBlock { .. } => {
if energy.get_unchecked().regen_rate != 0.0 { if energy.get_unchecked().regen_rate != 0.0 {
energy.get_mut_unchecked().regen_rate = 0.0 energy.get_mut_unchecked().regen_rate = 0.0
} }
}, },
_ => {}, // Non-combat abilities that consume energy;
// temporarily stall energy gain, but preserve regen_rate.
CharacterState::Roll { .. } | CharacterState::Climb { .. } => {},
} }
} }
} }