mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Tick rate now exposed as a variable.
This commit is contained in:
parent
a2d74b71c4
commit
8f7d45100d
@ -155,6 +155,7 @@ pub enum CharacterAbility {
|
|||||||
recover_duration: Duration,
|
recover_duration: Duration,
|
||||||
base_hps: u32,
|
base_hps: u32,
|
||||||
base_dps: u32,
|
base_dps: u32,
|
||||||
|
tick_rate: f32,
|
||||||
range: f32,
|
range: f32,
|
||||||
max_angle: f32,
|
max_angle: f32,
|
||||||
lifesteal_eff: f32,
|
lifesteal_eff: f32,
|
||||||
@ -521,6 +522,7 @@ impl From<&CharacterAbility> for CharacterState {
|
|||||||
recover_duration,
|
recover_duration,
|
||||||
base_hps,
|
base_hps,
|
||||||
base_dps,
|
base_dps,
|
||||||
|
tick_rate,
|
||||||
range,
|
range,
|
||||||
max_angle,
|
max_angle,
|
||||||
lifesteal_eff,
|
lifesteal_eff,
|
||||||
@ -529,11 +531,11 @@ impl From<&CharacterAbility> for CharacterState {
|
|||||||
exhausted: false,
|
exhausted: false,
|
||||||
particle_ori: None::<Vec3<f32>>,
|
particle_ori: None::<Vec3<f32>>,
|
||||||
buildup_duration: *buildup_duration,
|
buildup_duration: *buildup_duration,
|
||||||
cooldown_duration: Duration::from_millis(500),
|
cooldown_duration: Duration::default(),
|
||||||
cooldown_duration_default: Duration::from_millis(500),
|
|
||||||
recover_duration: *recover_duration,
|
recover_duration: *recover_duration,
|
||||||
base_hps: *base_hps,
|
base_hps: *base_hps,
|
||||||
base_dps: *base_dps,
|
base_dps: *base_dps,
|
||||||
|
tick_rate: *tick_rate,
|
||||||
range: *range,
|
range: *range,
|
||||||
max_angle: *max_angle,
|
max_angle: *max_angle,
|
||||||
lifesteal_eff: *lifesteal_eff,
|
lifesteal_eff: *lifesteal_eff,
|
||||||
|
@ -308,10 +308,11 @@ impl Tool {
|
|||||||
recover_duration: Duration::from_millis(250),
|
recover_duration: Duration::from_millis(250),
|
||||||
base_hps: (60.0 * self.base_power()) as u32,
|
base_hps: (60.0 * self.base_power()) as u32,
|
||||||
base_dps: (40.0 * self.base_power()) as u32,
|
base_dps: (40.0 * self.base_power()) as u32,
|
||||||
|
tick_rate: 2.0,
|
||||||
range: 25.0,
|
range: 25.0,
|
||||||
max_angle: 1.0,
|
max_angle: 1.0,
|
||||||
lifesteal_eff: 0.25,
|
lifesteal_eff: 0.25,
|
||||||
energy_regen: 10,
|
energy_regen: 100,
|
||||||
},
|
},
|
||||||
BasicRanged {
|
BasicRanged {
|
||||||
energy_cost: 800,
|
energy_cost: 800,
|
||||||
|
@ -17,14 +17,14 @@ pub struct Data {
|
|||||||
pub buildup_duration: Duration,
|
pub buildup_duration: Duration,
|
||||||
/// How long until weapon can deal another tick of damage
|
/// How long until weapon can deal another tick of damage
|
||||||
pub cooldown_duration: Duration,
|
pub cooldown_duration: Duration,
|
||||||
/// Value that cooldown_duration defaults to
|
|
||||||
pub cooldown_duration_default: Duration,
|
|
||||||
/// How long the state has until exiting
|
/// How long the state has until exiting
|
||||||
pub recover_duration: Duration,
|
pub recover_duration: Duration,
|
||||||
/// Base healing per second
|
/// Base healing per second
|
||||||
pub base_hps: u32,
|
pub base_hps: u32,
|
||||||
/// Base damage per second
|
/// Base damage per second
|
||||||
pub base_dps: u32,
|
pub base_dps: u32,
|
||||||
|
/// Ticks of damage/healing per second
|
||||||
|
pub tick_rate: f32,
|
||||||
/// Max range
|
/// Max range
|
||||||
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)
|
||||||
@ -43,8 +43,6 @@ impl CharacterBehavior for Data {
|
|||||||
handle_move(data, &mut update, 0.4);
|
handle_move(data, &mut update, 0.4);
|
||||||
handle_jump(data, &mut update);
|
handle_jump(data, &mut update);
|
||||||
|
|
||||||
let ticks_per_sec = 1.0 / self.cooldown_duration_default.as_secs_f32();
|
|
||||||
|
|
||||||
if self.buildup_duration != Duration::default() {
|
if self.buildup_duration != Duration::default() {
|
||||||
// Build up
|
// Build up
|
||||||
update.character = CharacterState::BasicBeam(Data {
|
update.character = CharacterState::BasicBeam(Data {
|
||||||
@ -55,18 +53,18 @@ impl CharacterBehavior for Data {
|
|||||||
.checked_sub(Duration::from_secs_f32(data.dt.0))
|
.checked_sub(Duration::from_secs_f32(data.dt.0))
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
cooldown_duration: self.cooldown_duration,
|
cooldown_duration: self.cooldown_duration,
|
||||||
cooldown_duration_default: self.cooldown_duration_default,
|
|
||||||
recover_duration: self.recover_duration,
|
recover_duration: self.recover_duration,
|
||||||
base_hps: self.base_hps,
|
base_hps: self.base_hps,
|
||||||
base_dps: self.base_dps,
|
base_dps: self.base_dps,
|
||||||
|
tick_rate: self.tick_rate,
|
||||||
range: self.range,
|
range: self.range,
|
||||||
max_angle: self.max_angle,
|
max_angle: self.max_angle,
|
||||||
lifesteal_eff: self.lifesteal_eff,
|
lifesteal_eff: self.lifesteal_eff,
|
||||||
energy_regen: self.energy_regen,
|
energy_regen: self.energy_regen,
|
||||||
});
|
});
|
||||||
} else if data.inputs.primary.is_pressed() && !self.exhausted {
|
} else if data.inputs.primary.is_pressed() && !self.exhausted {
|
||||||
let damage = (self.base_dps as f32 / ticks_per_sec) as u32;
|
let damage = (self.base_dps as f32 / self.tick_rate) as u32;
|
||||||
let heal = (self.base_hps as f32 / ticks_per_sec) as u32;
|
let heal = (self.base_hps as f32 / self.tick_rate) as u32;
|
||||||
// Hit attempt
|
// Hit attempt
|
||||||
data.updater.insert(data.entity, Attacking {
|
data.updater.insert(data.entity, Attacking {
|
||||||
base_damage: damage,
|
base_damage: damage,
|
||||||
@ -85,10 +83,10 @@ impl CharacterBehavior for Data {
|
|||||||
particle_ori: Some(*data.inputs.look_dir),
|
particle_ori: Some(*data.inputs.look_dir),
|
||||||
buildup_duration: self.buildup_duration,
|
buildup_duration: self.buildup_duration,
|
||||||
recover_duration: self.recover_duration,
|
recover_duration: self.recover_duration,
|
||||||
cooldown_duration: self.cooldown_duration_default,
|
cooldown_duration: Duration::from_secs_f32(1.0 / self.tick_rate),
|
||||||
cooldown_duration_default: self.cooldown_duration_default,
|
|
||||||
base_hps: self.base_hps,
|
base_hps: self.base_hps,
|
||||||
base_dps: self.base_dps,
|
base_dps: self.base_dps,
|
||||||
|
tick_rate: self.tick_rate,
|
||||||
range: self.range,
|
range: self.range,
|
||||||
max_angle: self.max_angle,
|
max_angle: self.max_angle,
|
||||||
lifesteal_eff: self.lifesteal_eff,
|
lifesteal_eff: self.lifesteal_eff,
|
||||||
@ -105,10 +103,10 @@ impl CharacterBehavior for Data {
|
|||||||
.cooldown_duration
|
.cooldown_duration
|
||||||
.checked_sub(Duration::from_secs_f32(data.dt.0))
|
.checked_sub(Duration::from_secs_f32(data.dt.0))
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
cooldown_duration_default: self.cooldown_duration_default,
|
|
||||||
recover_duration: self.recover_duration,
|
recover_duration: self.recover_duration,
|
||||||
base_hps: self.base_hps,
|
base_hps: self.base_hps,
|
||||||
base_dps: self.base_dps,
|
base_dps: self.base_dps,
|
||||||
|
tick_rate: self.tick_rate,
|
||||||
range: self.range,
|
range: self.range,
|
||||||
max_angle: self.max_angle,
|
max_angle: self.max_angle,
|
||||||
lifesteal_eff: self.lifesteal_eff,
|
lifesteal_eff: self.lifesteal_eff,
|
||||||
@ -120,10 +118,10 @@ impl CharacterBehavior for Data {
|
|||||||
particle_ori: Some(*data.inputs.look_dir),
|
particle_ori: Some(*data.inputs.look_dir),
|
||||||
buildup_duration: self.buildup_duration,
|
buildup_duration: self.buildup_duration,
|
||||||
recover_duration: self.recover_duration,
|
recover_duration: self.recover_duration,
|
||||||
cooldown_duration: self.cooldown_duration_default,
|
cooldown_duration: self.cooldown_duration,
|
||||||
cooldown_duration_default: self.cooldown_duration_default,
|
|
||||||
base_hps: self.base_hps,
|
base_hps: self.base_hps,
|
||||||
base_dps: self.base_dps,
|
base_dps: self.base_dps,
|
||||||
|
tick_rate: self.tick_rate,
|
||||||
range: self.range,
|
range: self.range,
|
||||||
max_angle: self.max_angle,
|
max_angle: self.max_angle,
|
||||||
lifesteal_eff: self.lifesteal_eff,
|
lifesteal_eff: self.lifesteal_eff,
|
||||||
@ -131,7 +129,7 @@ impl CharacterBehavior for Data {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Grant energy on successful hit
|
// Grant energy on successful hit
|
||||||
let energy = (self.energy_regen as f32 / ticks_per_sec) as i32;
|
let energy = (self.energy_regen as f32 / self.tick_rate) as i32;
|
||||||
update.energy.change_by(energy, EnergySource::HitEnemy);
|
update.energy.change_by(energy, EnergySource::HitEnemy);
|
||||||
} else if self.recover_duration != Duration::default() {
|
} else if self.recover_duration != Duration::default() {
|
||||||
// Recovery
|
// Recovery
|
||||||
@ -140,13 +138,13 @@ impl CharacterBehavior for Data {
|
|||||||
particle_ori: Some(*data.inputs.look_dir),
|
particle_ori: Some(*data.inputs.look_dir),
|
||||||
buildup_duration: self.buildup_duration,
|
buildup_duration: self.buildup_duration,
|
||||||
cooldown_duration: self.cooldown_duration,
|
cooldown_duration: self.cooldown_duration,
|
||||||
cooldown_duration_default: self.cooldown_duration_default,
|
|
||||||
recover_duration: self
|
recover_duration: self
|
||||||
.recover_duration
|
.recover_duration
|
||||||
.checked_sub(Duration::from_secs_f32(data.dt.0))
|
.checked_sub(Duration::from_secs_f32(data.dt.0))
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
base_hps: self.base_hps,
|
base_hps: self.base_hps,
|
||||||
base_dps: self.base_dps,
|
base_dps: self.base_dps,
|
||||||
|
tick_rate: self.tick_rate,
|
||||||
range: self.range,
|
range: self.range,
|
||||||
max_angle: self.max_angle,
|
max_angle: self.max_angle,
|
||||||
lifesteal_eff: self.lifesteal_eff,
|
lifesteal_eff: self.lifesteal_eff,
|
||||||
|
Loading…
Reference in New Issue
Block a user