mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
wip: impl Stats::attack_speed_modifier
This commit is contained in:
parent
e06bd0eaa3
commit
eea7eead2e
@ -151,6 +151,8 @@ pub enum BuffEffect {
|
||||
},
|
||||
/// Modifies move speed of target
|
||||
MovementSpeed(f32),
|
||||
/// Modifies attack speed of target
|
||||
AttackSpeed(f32),
|
||||
}
|
||||
|
||||
/// Actual de/buff.
|
||||
|
@ -26,6 +26,7 @@ pub struct Stats {
|
||||
pub damage_reduction: f32,
|
||||
pub max_health_modifier: f32,
|
||||
pub move_speed_modifier: f32,
|
||||
pub attack_speed_modifier: f32,
|
||||
}
|
||||
|
||||
impl Stats {
|
||||
@ -35,6 +36,7 @@ impl Stats {
|
||||
damage_reduction: 0.0,
|
||||
max_health_modifier: 1.0,
|
||||
move_speed_modifier: 1.0,
|
||||
attack_speed_modifier: 1.0,
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,6 +48,7 @@ impl Stats {
|
||||
damage_reduction: 0.0,
|
||||
max_health_modifier: 1.0,
|
||||
move_speed_modifier: 1.0,
|
||||
attack_speed_modifier: 1.0,
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,6 +57,7 @@ impl Stats {
|
||||
self.damage_reduction = 0.0;
|
||||
self.max_health_modifier = 1.0;
|
||||
self.move_speed_modifier = 1.0;
|
||||
self.attack_speed_modifier = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -764,6 +764,12 @@ pub fn input_is_pressed(data: &JoinData, input: InputKind) -> bool {
|
||||
data.controller.queued_inputs.contains_key(&input)
|
||||
}
|
||||
|
||||
pub fn tick_attack_duraction(data: &JoinData, timer: Duration) -> Duration {
|
||||
timer
|
||||
.checked_add(data.dt.0 * data.stats.attack_speed_modifier)
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Determines what portion a state is in. Used in all attacks (eventually). Is
|
||||
/// used to control aspects of animation code, as well as logic within the
|
||||
/// character states.
|
||||
|
@ -9,6 +9,7 @@ use common::{
|
||||
Damage, DamageSource,
|
||||
};
|
||||
use common_ecs::{Job, Origin, Phase, System};
|
||||
use hashbrown::HashMap;
|
||||
use specs::{
|
||||
shred::ResourceId, Entities, Join, Read, ReadStorage, SystemData, World, WriteStorage,
|
||||
};
|
||||
@ -57,7 +58,10 @@ impl<'a> System<'a> for Sys {
|
||||
)
|
||||
.join()
|
||||
{
|
||||
let (buff_comp_kinds, buff_comp_buffs) = buff_comp.parts();
|
||||
let (buff_comp_kinds, buff_comp_buffs): (
|
||||
&HashMap<BuffKind, Vec<BuffId>>,
|
||||
&mut HashMap<BuffId, Buff>,
|
||||
) = buff_comp.parts();
|
||||
let mut expired_buffs = Vec::<BuffId>::new();
|
||||
// For each buff kind present on entity, if the buff kind queues, only ticks
|
||||
// duration of strongest buff of that kind, else it ticks durations of all buffs
|
||||
@ -207,6 +211,9 @@ impl<'a> System<'a> for Sys {
|
||||
BuffEffect::MovementSpeed(ms) => {
|
||||
stat.move_speed_modifier *= *ms;
|
||||
},
|
||||
BuffEffect::AttackSpeed(ms) => {
|
||||
stat.attack_speed_modifier *= *ms;
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user