Experimental tweeks to triplestrike

This commit is contained in:
timokoesters 2020-03-20 15:05:40 +01:00
parent 68192738ee
commit 3ec2cc08b3
6 changed files with 5 additions and 87 deletions

View File

@ -30,7 +30,6 @@ pub enum CharacterAbility {
},
BasicBlock,
Roll,
ChargeAttack,
TimedCombo {
buildup_duration: Duration,
recover_duration: Duration,
@ -134,9 +133,6 @@ impl From<&CharacterAbility> for CharacterState {
CharacterAbility::Roll => CharacterState::Roll(roll::Data {
remaining_duration: Duration::from_millis(600),
}),
CharacterAbility::ChargeAttack => CharacterState::ChargeAttack(charge_attack::Data {
remaining_duration: Duration::from_millis(600),
}),
CharacterAbility::TimedCombo {
buildup_duration,
recover_duration,

View File

@ -1,5 +1,5 @@
use crate::{
comp::{Energy, Ori, Pos, ToolData, Vel},
comp::{Energy, Ori, Pos, Vel},
event::{LocalEvent, ServerEvent},
states::*,
};
@ -30,8 +30,6 @@ pub enum CharacterState {
Equipping(equipping::Data),
/// Player is holding a weapon and can perform other actions
Wielding,
/// Player rushes forward and slams an enemy with their weapon
ChargeAttack(charge_attack::Data),
/// A dodge where player can roll
Roll(roll::Data),
/// A basic melee attack (e.g. sword)
@ -57,8 +55,8 @@ impl CharacterState {
| CharacterState::BasicMelee(_)
| CharacterState::BasicRanged(_)
| CharacterState::DashMelee(_)
| CharacterState::TripleStrike(_)
| CharacterState::TimedCombo(_)
| CharacterState::ChargeAttack(_)
| CharacterState::BasicBlock => true,
_ => false,
}
@ -77,7 +75,7 @@ impl CharacterState {
| CharacterState::BasicRanged(_)
| CharacterState::TimedCombo(_)
| CharacterState::DashMelee(_)
| CharacterState::ChargeAttack(_) => true,
| CharacterState::TripleStrike(_) => true,
_ => false,
}
}

View File

@ -1,70 +0,0 @@
use super::utils::*;
use crate::{
comp::{CharacterState::*, HealthChange, HealthSource, StateUpdate},
event::ServerEvent,
sys::character_behavior::{CharacterBehavior, JoinData},
};
use std::{collections::VecDeque, time::Duration};
use vek::Vec3;
const CHARGE_SPEED: f32 = 20.0;
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
pub struct Data {
/// How long the state has until exiting
pub remaining_duration: Duration,
}
impl CharacterBehavior for Data {
fn behavior(&self, data: &JoinData) -> StateUpdate {
let mut update = StateUpdate {
pos: *data.pos,
vel: *data.vel,
ori: *data.ori,
character: data.character.clone(),
energy: *data.energy,
local_events: VecDeque::new(),
server_events: VecDeque::new(),
};
// Move player
update.vel.0 = Vec3::new(0.0, 0.0, update.vel.0.z)
+ (update.vel.0 * Vec3::new(1.0, 1.0, 0.0)
+ 1.5 * data.inputs.move_dir.try_normalized().unwrap_or_default())
.try_normalized()
.unwrap_or_default()
* CHARGE_SPEED;
// Check if hitting another entity
if let Some(uid_b) = data.physics.touch_entity {
// Send Damage event
update.server_events.push_front(ServerEvent::Damage {
uid: uid_b,
change: HealthChange {
amount: -20,
cause: HealthSource::Attack { by: *data.uid },
},
});
// Go back to wielding or idling
attempt_wield(data, &mut update);
return update;
}
// Check if charge timed out or can't keep moving forward
if self.remaining_duration == Duration::default() || update.vel.0.magnitude_squared() < 10.0
{
attempt_wield(data, &mut update);
return update;
}
// Tick remaining-duration and keep charging
update.character = ChargeAttack(Data {
remaining_duration: self
.remaining_duration
.checked_sub(Duration::from_secs_f32(data.dt.0))
.unwrap_or_default(),
});
update
}
}

View File

@ -2,7 +2,6 @@ pub mod basic_block;
pub mod basic_melee;
pub mod basic_ranged;
pub mod boost;
pub mod charge_attack;
pub mod climb;
pub mod dash_melee;
pub mod equipping;

View File

@ -55,6 +55,8 @@ impl CharacterBehavior for Data {
return update;
}
handle_move(data, &mut update);
if self.stage < 3 {
if new_stage_time_active < Duration::from_millis(STAGE_DURATION / 3) {
// Move player forward while in first third of each stage
@ -77,9 +79,6 @@ impl CharacterBehavior for Data {
} else if new_stage_time_active > Duration::from_millis(STAGE_DURATION / 2)
&& !self.stage_exhausted
{
// Allow player to influence orientation a little
handle_move(data, &mut update);
// Try to deal damage in second half of stage
data.updater.insert(data.entity, Attacking {
base_damage: self.base_damage * (self.stage as u32 + 1),
@ -95,9 +94,6 @@ impl CharacterBehavior for Data {
stage_exhausted: true,
});
} else if new_stage_time_active > Duration::from_millis(STAGE_DURATION) {
// Allow player to influence orientation a little
handle_move(data, &mut update);
update.character = CharacterState::TripleStrike(Data {
base_damage: self.base_damage,
stage: self.stage + 1,

View File

@ -180,7 +180,6 @@ impl<'a> System<'a> for Sys {
CharacterState::Roll(data) => data.behavior(&j),
CharacterState::Wielding => states::wielding::Data.behavior(&j),
CharacterState::Equipping(data) => data.behavior(&j),
CharacterState::ChargeAttack(data) => data.behavior(&j),
CharacterState::TripleStrike(data) => data.behavior(&j),
CharacterState::BasicMelee(data) => data.behavior(&j),
CharacterState::BasicRanged(data) => data.behavior(&j),