diff --git a/common/src/comp/stats.rs b/common/src/comp/stats.rs index bc1a9de487..09ebc940a1 100644 --- a/common/src/comp/stats.rs +++ b/common/src/comp/stats.rs @@ -168,19 +168,18 @@ impl Stats { } // TODO: Delete this once stat points will be a thing - pub fn update_hp_bonus(&mut self, level: u32) { - self.health - .set_maximum(self.health.maximum() + (10 * level) / 2); + pub fn update_max_hp(&mut self) { + self.health.set_maximum(22 * self.level.amount); } } impl Stats { pub fn new(name: String, main: Option) -> Self { - Self { + let mut stats = Self { name, health: Health { - current: 100, - maximum: 100, + current: 0, + maximum: 0, last_change: None, }, level: Level { amount: 1 }, @@ -198,7 +197,14 @@ impl Stats { alt: None, }, is_dead: false, - } + }; + + stats.update_max_hp(); + stats + .health + .set_to(stats.health.maximum(), HealthSource::Revive); + + stats } pub fn with_max_health(mut self, amount: u32) -> Self { diff --git a/common/src/sys/stats.rs b/common/src/sys/stats.rs index 6a6ebc8bf7..d1f503d456 100644 --- a/common/src/sys/stats.rs +++ b/common/src/sys/stats.rs @@ -45,7 +45,7 @@ impl<'a> System<'a> for Sys { stat.exp.change_maximum_by(25); stat.level.change_by(1); } - stat.update_hp_bonus(stat.level.level()); + stat.update_max_hp(); stat.health .set_to(stat.health.maximum(), HealthSource::LevelUp) } diff --git a/server/src/lib.rs b/server/src/lib.rs index 82809edb3f..b78915c31e 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -357,11 +357,9 @@ impl Server { ecs.entity_from_uid(by.into()).map(|attacker| { if let Some(attacker_stats) = stats.get_mut(attacker) { // TODO: Discuss whether we should give EXP by Player Killing or not. - attacker_stats.exp.change_by( - (entity_stats.health.maximum() as f64 / 10.0 - + entity_stats.level.level() as f64 * 10.0) - as i64, - ); + attacker_stats + .exp + .change_by((entity_stats.level.level() * 10) as i64); } }); } @@ -565,10 +563,7 @@ impl Server { let mut scale = 1.0; // TODO: Remove this and implement scaling or level depending on stuff like species instead - stats.level.set_level(rand::thread_rng().gen_range(1, 20)); - if stats.level.level() > 1 { - stats.update_hp_bonus(stats.level.level()); - } + stats.level.set_level(rand::thread_rng().gen_range(1, 3)); if npc.boss { if rand::random::() < 0.8 { @@ -581,10 +576,11 @@ impl Server { ); body = comp::Body::Humanoid(comp::humanoid::Body::random()); } - stats = stats.with_max_health(500 + rand::random::() % 400); + stats.level.set_level(rand::thread_rng().gen_range(10, 50)); scale = 2.5 + rand::random::(); } + stats.update_max_hp(); self.create_npc(comp::Pos(npc.pos), stats, body) .with(comp::Agent::enemy()) .with(comp::Scale(scale))