mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Better health accessors methods
This commit is contained in:
parent
5e4f383952
commit
23cfe50455
@ -50,10 +50,6 @@ impl Health {
|
||||
self.last_change = Some((amount, 0.0, cause));
|
||||
}
|
||||
|
||||
pub fn set_current(&mut self, amount: u32) {
|
||||
self.current = amount.min(self.maximum);
|
||||
}
|
||||
|
||||
pub fn set_maximum(&mut self, amount: u32) {
|
||||
self.maximum = amount;
|
||||
self.current = self.current.min(self.maximum);
|
||||
@ -140,6 +136,12 @@ impl Stats {
|
||||
is_dead: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_max_health(mut self, amount: u32) -> Self {
|
||||
self.health.maximum = amount;
|
||||
self.health.current = amount;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Component for Stats {
|
||||
|
@ -275,9 +275,8 @@ impl Server {
|
||||
let mut scale = 1.0;
|
||||
|
||||
if npc.boss {
|
||||
stats.health.set_maximum(400);
|
||||
stats.health.set_current(400);
|
||||
scale = 2.5;
|
||||
stats = stats.with_max_health(300 + rand::random::<u32>() % 400);
|
||||
scale = 1.8 + rand::random::<f32>().fract();
|
||||
body = comp::Body::Humanoid(comp::humanoid::Body::random());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user