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:
@ -50,10 +50,6 @@ impl Health {
|
|||||||
self.last_change = Some((amount, 0.0, cause));
|
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) {
|
pub fn set_maximum(&mut self, amount: u32) {
|
||||||
self.maximum = amount;
|
self.maximum = amount;
|
||||||
self.current = self.current.min(self.maximum);
|
self.current = self.current.min(self.maximum);
|
||||||
@ -140,6 +136,12 @@ impl Stats {
|
|||||||
is_dead: false,
|
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 {
|
impl Component for Stats {
|
||||||
|
@ -275,9 +275,8 @@ impl Server {
|
|||||||
let mut scale = 1.0;
|
let mut scale = 1.0;
|
||||||
|
|
||||||
if npc.boss {
|
if npc.boss {
|
||||||
stats.health.set_maximum(400);
|
stats = stats.with_max_health(300 + rand::random::<u32>() % 400);
|
||||||
stats.health.set_current(400);
|
scale = 1.8 + rand::random::<f32>().fract();
|
||||||
scale = 2.5;
|
|
||||||
body = comp::Body::Humanoid(comp::humanoid::Body::random());
|
body = comp::Body::Humanoid(comp::humanoid::Body::random());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user