Adds a speed variable to charged states

This commit is contained in:
Snowram 2020-11-10 11:34:22 +01:00
parent 512fe52e5f
commit bed3a5c70a
4 changed files with 41 additions and 11 deletions

View File

@ -166,6 +166,7 @@ pub enum CharacterAbility {
max_knockback: f32,
range: f32,
max_angle: f32,
speed: f32,
charge_duration: Duration,
swing_duration: Duration,
recover_duration: Duration,
@ -177,6 +178,7 @@ pub enum CharacterAbility {
max_damage: u32,
initial_knockback: f32,
max_knockback: f32,
speed: f32,
buildup_duration: Duration,
charge_duration: Duration,
recover_duration: Duration,
@ -594,6 +596,7 @@ impl From<(&CharacterAbility, AbilityKey)> for CharacterState {
max_damage,
initial_knockback,
max_knockback,
speed,
charge_duration,
swing_duration,
recover_duration,
@ -607,6 +610,7 @@ impl From<(&CharacterAbility, AbilityKey)> for CharacterState {
max_damage: *max_damage,
initial_knockback: *initial_knockback,
max_knockback: *max_knockback,
speed: *speed,
range: *range,
max_angle: *max_angle,
charge_duration: *charge_duration,
@ -626,6 +630,7 @@ impl From<(&CharacterAbility, AbilityKey)> for CharacterState {
max_damage,
initial_knockback,
max_knockback,
speed,
buildup_duration,
charge_duration,
recover_duration,
@ -642,6 +647,7 @@ impl From<(&CharacterAbility, AbilityKey)> for CharacterState {
energy_drain: *energy_drain,
initial_damage: *initial_damage,
max_damage: *max_damage,
speed: *speed,
initial_knockback: *initial_knockback,
max_knockback: *max_knockback,
projectile_body: *projectile_body,

View File

@ -162,7 +162,7 @@ impl Tool {
energy_drain: 500,
forward_speed: 4.0,
buildup_duration: self.adjusted_duration(250),
charge_duration: self.adjusted_duration(600),
charge_duration: Duration::from_millis(600),
swing_duration: self.adjusted_duration(100),
recover_duration: self.adjusted_duration(500),
infinite_charge: true,
@ -279,7 +279,8 @@ impl Tool {
max_knockback: 60.0,
range: 3.5,
max_angle: 30.0,
charge_duration: self.adjusted_duration(1200),
speed: self.base_speed(),
charge_duration: Duration::from_millis(1200),
swing_duration: self.adjusted_duration(200),
recover_duration: self.adjusted_duration(300),
},
@ -352,8 +353,9 @@ impl Tool {
max_damage: (200.0 * self.base_power()) as u32,
initial_knockback: 10.0,
max_knockback: 20.0,
speed: self.base_speed(),
buildup_duration: self.adjusted_duration(100),
charge_duration: self.adjusted_duration(1500),
charge_duration: Duration::from_millis(1500),
recover_duration: self.adjusted_duration(500),
projectile_body: Body::Object(object::Body::MultiArrow),
projectile_light: None,

View File

@ -26,6 +26,8 @@ pub struct StaticData {
pub range: f32,
/// Max angle (45.0 will give you a 90.0 angle window)
pub max_angle: f32,
/// Speed stat of the weapon
pub speed: f32,
/// How long it takes to charge the weapon to max damage and knockback
pub charge_duration: Duration,
/// How long the weapon is swinging for
@ -72,7 +74,9 @@ impl CharacterBehavior for Data {
update.character = CharacterState::ChargedMelee(Data {
timer: self
.timer
.checked_add(Duration::from_secs_f32(data.dt.0))
.checked_add(Duration::from_secs_f32(
data.dt.0 * self.static_data.speed,
))
.unwrap_or_default(),
charge_amount: charge,
..*self
@ -80,7 +84,9 @@ impl CharacterBehavior for Data {
// Consumes energy if there's enough left and RMB is held down
update.energy.change_by(EnergyChange {
amount: -(self.static_data.energy_drain as f32 * data.dt.0) as i32,
amount: -(self.static_data.energy_drain as f32
* data.dt.0
* self.static_data.speed) as i32,
source: EnergySource::Ability,
});
} else if ability_key_is_pressed(data, self.static_data.ability_key)
@ -90,14 +96,19 @@ impl CharacterBehavior for Data {
update.character = CharacterState::ChargedMelee(Data {
timer: self
.timer
.checked_add(Duration::from_secs_f32(data.dt.0))
.checked_add(Duration::from_secs_f32(
data.dt.0 * self.static_data.speed,
))
.unwrap_or_default(),
..*self
});
// Consumes energy if there's enough left and RMB is held down
update.energy.change_by(EnergyChange {
amount: -(self.static_data.energy_drain as f32 * data.dt.0 / 5.0) as i32,
amount: -(self.static_data.energy_drain as f32
* data.dt.0
* self.static_data.speed
/ 5.0) as i32,
source: EnergySource::Ability,
});
} else {

View File

@ -31,6 +31,8 @@ pub struct StaticData {
pub initial_knockback: f32,
/// How much knockback there is at max charge
pub max_knockback: f32,
/// Speed stat of the weapon
pub speed: f32,
/// Projectile information
pub projectile_body: Body,
pub projectile_light: Option<LightEmitter>,
@ -146,14 +148,18 @@ impl CharacterBehavior for Data {
update.character = CharacterState::ChargedRanged(Data {
timer: self
.timer
.checked_add(Duration::from_secs_f32(data.dt.0))
.checked_add(Duration::from_secs_f32(
data.dt.0 * self.static_data.speed,
))
.unwrap_or_default(),
..*self
});
// Consumes energy if there's enough left and RMB is held down
update.energy.change_by(EnergyChange {
amount: -(self.static_data.energy_drain as f32 * data.dt.0) as i32,
amount: -(self.static_data.energy_drain as f32
* data.dt.0
* self.static_data.speed) as i32,
source: EnergySource::Ability,
});
} else if ability_key_is_pressed(data, self.static_data.ability_key) {
@ -161,14 +167,19 @@ impl CharacterBehavior for Data {
update.character = CharacterState::ChargedRanged(Data {
timer: self
.timer
.checked_add(Duration::from_secs_f32(data.dt.0))
.checked_add(Duration::from_secs_f32(
data.dt.0 * self.static_data.speed,
))
.unwrap_or_default(),
..*self
});
// Consumes energy if there's enough left and RMB is held down
update.energy.change_by(EnergyChange {
amount: -(self.static_data.energy_drain as f32 * data.dt.0 / 5.0) as i32,
amount: -(self.static_data.energy_drain as f32
* data.dt.0
* self.static_data.speed
/ 5.0) as i32,
source: EnergySource::Ability,
});
}