mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Adds a speed variable to charged states
This commit is contained in:
parent
512fe52e5f
commit
bed3a5c70a
@ -166,6 +166,7 @@ pub enum CharacterAbility {
|
|||||||
max_knockback: f32,
|
max_knockback: f32,
|
||||||
range: f32,
|
range: f32,
|
||||||
max_angle: f32,
|
max_angle: f32,
|
||||||
|
speed: f32,
|
||||||
charge_duration: Duration,
|
charge_duration: Duration,
|
||||||
swing_duration: Duration,
|
swing_duration: Duration,
|
||||||
recover_duration: Duration,
|
recover_duration: Duration,
|
||||||
@ -177,6 +178,7 @@ pub enum CharacterAbility {
|
|||||||
max_damage: u32,
|
max_damage: u32,
|
||||||
initial_knockback: f32,
|
initial_knockback: f32,
|
||||||
max_knockback: f32,
|
max_knockback: f32,
|
||||||
|
speed: f32,
|
||||||
buildup_duration: Duration,
|
buildup_duration: Duration,
|
||||||
charge_duration: Duration,
|
charge_duration: Duration,
|
||||||
recover_duration: Duration,
|
recover_duration: Duration,
|
||||||
@ -594,6 +596,7 @@ impl From<(&CharacterAbility, AbilityKey)> for CharacterState {
|
|||||||
max_damage,
|
max_damage,
|
||||||
initial_knockback,
|
initial_knockback,
|
||||||
max_knockback,
|
max_knockback,
|
||||||
|
speed,
|
||||||
charge_duration,
|
charge_duration,
|
||||||
swing_duration,
|
swing_duration,
|
||||||
recover_duration,
|
recover_duration,
|
||||||
@ -607,6 +610,7 @@ impl From<(&CharacterAbility, AbilityKey)> for CharacterState {
|
|||||||
max_damage: *max_damage,
|
max_damage: *max_damage,
|
||||||
initial_knockback: *initial_knockback,
|
initial_knockback: *initial_knockback,
|
||||||
max_knockback: *max_knockback,
|
max_knockback: *max_knockback,
|
||||||
|
speed: *speed,
|
||||||
range: *range,
|
range: *range,
|
||||||
max_angle: *max_angle,
|
max_angle: *max_angle,
|
||||||
charge_duration: *charge_duration,
|
charge_duration: *charge_duration,
|
||||||
@ -626,6 +630,7 @@ impl From<(&CharacterAbility, AbilityKey)> for CharacterState {
|
|||||||
max_damage,
|
max_damage,
|
||||||
initial_knockback,
|
initial_knockback,
|
||||||
max_knockback,
|
max_knockback,
|
||||||
|
speed,
|
||||||
buildup_duration,
|
buildup_duration,
|
||||||
charge_duration,
|
charge_duration,
|
||||||
recover_duration,
|
recover_duration,
|
||||||
@ -642,6 +647,7 @@ impl From<(&CharacterAbility, AbilityKey)> for CharacterState {
|
|||||||
energy_drain: *energy_drain,
|
energy_drain: *energy_drain,
|
||||||
initial_damage: *initial_damage,
|
initial_damage: *initial_damage,
|
||||||
max_damage: *max_damage,
|
max_damage: *max_damage,
|
||||||
|
speed: *speed,
|
||||||
initial_knockback: *initial_knockback,
|
initial_knockback: *initial_knockback,
|
||||||
max_knockback: *max_knockback,
|
max_knockback: *max_knockback,
|
||||||
projectile_body: *projectile_body,
|
projectile_body: *projectile_body,
|
||||||
|
@ -162,7 +162,7 @@ impl Tool {
|
|||||||
energy_drain: 500,
|
energy_drain: 500,
|
||||||
forward_speed: 4.0,
|
forward_speed: 4.0,
|
||||||
buildup_duration: self.adjusted_duration(250),
|
buildup_duration: self.adjusted_duration(250),
|
||||||
charge_duration: self.adjusted_duration(600),
|
charge_duration: Duration::from_millis(600),
|
||||||
swing_duration: self.adjusted_duration(100),
|
swing_duration: self.adjusted_duration(100),
|
||||||
recover_duration: self.adjusted_duration(500),
|
recover_duration: self.adjusted_duration(500),
|
||||||
infinite_charge: true,
|
infinite_charge: true,
|
||||||
@ -279,7 +279,8 @@ impl Tool {
|
|||||||
max_knockback: 60.0,
|
max_knockback: 60.0,
|
||||||
range: 3.5,
|
range: 3.5,
|
||||||
max_angle: 30.0,
|
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),
|
swing_duration: self.adjusted_duration(200),
|
||||||
recover_duration: self.adjusted_duration(300),
|
recover_duration: self.adjusted_duration(300),
|
||||||
},
|
},
|
||||||
@ -352,8 +353,9 @@ impl Tool {
|
|||||||
max_damage: (200.0 * self.base_power()) as u32,
|
max_damage: (200.0 * self.base_power()) as u32,
|
||||||
initial_knockback: 10.0,
|
initial_knockback: 10.0,
|
||||||
max_knockback: 20.0,
|
max_knockback: 20.0,
|
||||||
|
speed: self.base_speed(),
|
||||||
buildup_duration: self.adjusted_duration(100),
|
buildup_duration: self.adjusted_duration(100),
|
||||||
charge_duration: self.adjusted_duration(1500),
|
charge_duration: Duration::from_millis(1500),
|
||||||
recover_duration: self.adjusted_duration(500),
|
recover_duration: self.adjusted_duration(500),
|
||||||
projectile_body: Body::Object(object::Body::MultiArrow),
|
projectile_body: Body::Object(object::Body::MultiArrow),
|
||||||
projectile_light: None,
|
projectile_light: None,
|
||||||
|
@ -26,6 +26,8 @@ pub struct StaticData {
|
|||||||
pub range: f32,
|
pub range: f32,
|
||||||
/// Max angle (45.0 will give you a 90.0 angle window)
|
/// Max angle (45.0 will give you a 90.0 angle window)
|
||||||
pub max_angle: f32,
|
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
|
/// How long it takes to charge the weapon to max damage and knockback
|
||||||
pub charge_duration: Duration,
|
pub charge_duration: Duration,
|
||||||
/// How long the weapon is swinging for
|
/// How long the weapon is swinging for
|
||||||
@ -72,7 +74,9 @@ impl CharacterBehavior for Data {
|
|||||||
update.character = CharacterState::ChargedMelee(Data {
|
update.character = CharacterState::ChargedMelee(Data {
|
||||||
timer: self
|
timer: self
|
||||||
.timer
|
.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(),
|
.unwrap_or_default(),
|
||||||
charge_amount: charge,
|
charge_amount: charge,
|
||||||
..*self
|
..*self
|
||||||
@ -80,7 +84,9 @@ impl CharacterBehavior for Data {
|
|||||||
|
|
||||||
// Consumes energy if there's enough left and RMB is held down
|
// Consumes energy if there's enough left and RMB is held down
|
||||||
update.energy.change_by(EnergyChange {
|
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,
|
source: EnergySource::Ability,
|
||||||
});
|
});
|
||||||
} else if ability_key_is_pressed(data, self.static_data.ability_key)
|
} 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 {
|
update.character = CharacterState::ChargedMelee(Data {
|
||||||
timer: self
|
timer: self
|
||||||
.timer
|
.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(),
|
.unwrap_or_default(),
|
||||||
..*self
|
..*self
|
||||||
});
|
});
|
||||||
|
|
||||||
// Consumes energy if there's enough left and RMB is held down
|
// Consumes energy if there's enough left and RMB is held down
|
||||||
update.energy.change_by(EnergyChange {
|
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,
|
source: EnergySource::Ability,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -31,6 +31,8 @@ pub struct StaticData {
|
|||||||
pub initial_knockback: f32,
|
pub initial_knockback: f32,
|
||||||
/// How much knockback there is at max charge
|
/// How much knockback there is at max charge
|
||||||
pub max_knockback: f32,
|
pub max_knockback: f32,
|
||||||
|
/// Speed stat of the weapon
|
||||||
|
pub speed: f32,
|
||||||
/// Projectile information
|
/// Projectile information
|
||||||
pub projectile_body: Body,
|
pub projectile_body: Body,
|
||||||
pub projectile_light: Option<LightEmitter>,
|
pub projectile_light: Option<LightEmitter>,
|
||||||
@ -146,14 +148,18 @@ impl CharacterBehavior for Data {
|
|||||||
update.character = CharacterState::ChargedRanged(Data {
|
update.character = CharacterState::ChargedRanged(Data {
|
||||||
timer: self
|
timer: self
|
||||||
.timer
|
.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(),
|
.unwrap_or_default(),
|
||||||
..*self
|
..*self
|
||||||
});
|
});
|
||||||
|
|
||||||
// Consumes energy if there's enough left and RMB is held down
|
// Consumes energy if there's enough left and RMB is held down
|
||||||
update.energy.change_by(EnergyChange {
|
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,
|
source: EnergySource::Ability,
|
||||||
});
|
});
|
||||||
} else if ability_key_is_pressed(data, self.static_data.ability_key) {
|
} 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 {
|
update.character = CharacterState::ChargedRanged(Data {
|
||||||
timer: self
|
timer: self
|
||||||
.timer
|
.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(),
|
.unwrap_or_default(),
|
||||||
..*self
|
..*self
|
||||||
});
|
});
|
||||||
|
|
||||||
// Consumes energy if there's enough left and RMB is held down
|
// Consumes energy if there's enough left and RMB is held down
|
||||||
update.energy.change_by(EnergyChange {
|
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,
|
source: EnergySource::Ability,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user