mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'qutrin/npc-levels' into 'master'
Enemies spawn with random levels, Nametags display levels See merge request veloren/veloren!532
This commit is contained in:
commit
954881d84d
@ -133,10 +133,9 @@ impl Exp {
|
||||
}
|
||||
|
||||
impl Level {
|
||||
// TODO: Uncomment when needed
|
||||
// pub fn set_level(&mut self, level: u32) {
|
||||
// self.amount = level;
|
||||
// }
|
||||
pub fn set_level(&mut self, level: u32) {
|
||||
self.amount = level;
|
||||
}
|
||||
|
||||
pub fn level(&self) -> u32 {
|
||||
self.amount
|
||||
@ -167,6 +166,12 @@ impl Stats {
|
||||
.set_to(self.health.maximum(), HealthSource::Revive);
|
||||
self.is_dead = false;
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
impl Stats {
|
||||
|
@ -40,10 +40,12 @@ impl<'a> System<'a> for Sys {
|
||||
}
|
||||
|
||||
if stat.exp.current() >= stat.exp.maximum() {
|
||||
while stat.exp.current() >= stat.exp.maximum() {
|
||||
stat.exp.change_by(-(stat.exp.maximum() as i64));
|
||||
stat.exp.change_maximum_by(25);
|
||||
stat.level.change_by(1);
|
||||
stat.health.set_maximum(stat.health.maximum() + 10);
|
||||
}
|
||||
stat.update_hp_bonus(stat.level.level());
|
||||
stat.health
|
||||
.set_to(stat.health.maximum(), HealthSource::LevelUp)
|
||||
}
|
||||
|
@ -196,14 +196,14 @@ lazy_static! {
|
||||
"waypoint",
|
||||
"{}",
|
||||
"/waypoint : Set your waypoint to your current position",
|
||||
true,
|
||||
false,
|
||||
handle_waypoint,
|
||||
),
|
||||
ChatCommand::new(
|
||||
"adminify",
|
||||
"{}",
|
||||
"/adminify <playername> : Temporarily gives a player admin permissions or removes them",
|
||||
false, // TODO: NO
|
||||
true,
|
||||
handle_adminify,
|
||||
),
|
||||
ChatCommand::new(
|
||||
|
@ -560,6 +560,12 @@ 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());
|
||||
}
|
||||
|
||||
if npc.boss {
|
||||
if rand::random::<f32>() < 0.8 {
|
||||
stats = comp::Stats::new(
|
||||
|
@ -489,7 +489,8 @@ impl Hud {
|
||||
let mut health_back_id_walker = self.ids.health_bar_backs.walk();
|
||||
|
||||
// Render Name Tags
|
||||
for (pos, name, scale) in (&entities, &pos, &stats, players.maybe(), scales.maybe())
|
||||
for (pos, name, level, scale) in
|
||||
(&entities, &pos, &stats, players.maybe(), scales.maybe())
|
||||
.join()
|
||||
.filter(|(entity, _, stats, _, _)| *entity != me && !stats.is_dead)
|
||||
// Don't process nametags outside the vd (visibility further limited by ui backend)
|
||||
@ -509,16 +510,17 @@ impl Hud {
|
||||
} else {
|
||||
&stats.name
|
||||
};
|
||||
(pos.0, name, scale)
|
||||
(pos.0, name, stats.level, scale)
|
||||
})
|
||||
{
|
||||
let info = format!("{} Level {}", name, level.level());
|
||||
let scale = scale.map(|s| s.0).unwrap_or(1.0);
|
||||
|
||||
let id = name_id_walker.next(
|
||||
&mut self.ids.name_tags,
|
||||
&mut ui_widgets.widget_id_generator(),
|
||||
);
|
||||
Text::new(&name)
|
||||
Text::new(&info)
|
||||
.font_size(20)
|
||||
.color(Color::Rgba(0.61, 0.61, 0.89, 1.0))
|
||||
.x_y(0.0, 0.0)
|
||||
|
Loading…
Reference in New Issue
Block a user