improvement: enemy balance

This commit is contained in:
timokoesters
2020-01-20 17:42:35 +01:00
committed by Pfauenauge90
parent 0223a60a1e
commit 2e8bf9d212
5 changed files with 16 additions and 8 deletions

View File

@ -71,7 +71,8 @@ impl Health {
self.last_change = (0.0, change); self.last_change = (0.0, change);
} }
pub fn set_maximum(&mut self, amount: u32) { // This is private because max hp is based on the level
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);
} }
@ -160,7 +161,7 @@ impl Stats {
// TODO: Delete this once stat points will be a thing // TODO: Delete this once stat points will be a thing
pub fn update_max_hp(&mut self) { pub fn update_max_hp(&mut self) {
self.health.set_maximum(42 * self.level.amount); self.health.set_maximum(27 + 15 * self.level.amount);
} }
} }

View File

@ -132,7 +132,7 @@ impl<'a> System<'a> for Sys {
} }
} }
Agent::Enemy { bearing, target } => { Agent::Enemy { bearing, target } => {
const SIGHT_DIST: f32 = 30.0; const SIGHT_DIST: f32 = 18.0;
const MIN_ATTACK_DIST: f32 = 3.25; const MIN_ATTACK_DIST: f32 = 3.25;
let mut choose_new = false; let mut choose_new = false;

View File

@ -74,7 +74,7 @@ impl<'a> System<'a> for Sys {
{ {
kind.attack_recover_duration() kind.attack_recover_duration()
} else { } else {
Duration::from_secs(1) Duration::from_millis(250)
}; };
let (deal_damage, should_end) = if let Some(Attack { time_left, applied }) = let (deal_damage, should_end) = if let Some(Attack { time_left, applied }) =

View File

@ -140,7 +140,7 @@ impl Sys {
// Attack // Attack
if !character.action.is_attack() { if !character.action.is_attack() {
Attack { Attack {
time_left: Duration::from_millis(100), time_left: Duration::from_millis(250),
applied: false, applied: false,
} }
} else { } else {

View File

@ -2,7 +2,7 @@ use super::SysTimer;
use crate::{chunk_generator::ChunkGenerator, client::Client, Tick}; use crate::{chunk_generator::ChunkGenerator, client::Client, Tick};
use common::{ use common::{
assets, assets,
comp::{self, Player, Pos}, comp::{self, item, Player, Pos},
event::{EventBus, ServerEvent}, event::{EventBus, ServerEvent},
msg::ServerMsg, msg::ServerMsg,
state::TerrainChanges, state::TerrainChanges,
@ -111,7 +111,7 @@ impl<'a> System<'a> for Sys {
let mut scale = 1.0; let mut scale = 1.0;
// TODO: Remove this and implement scaling or level depending on stuff like species instead // TODO: Remove this and implement scaling or level depending on stuff like species instead
stats.level.set_level(rand::thread_rng().gen_range(1, 10)); stats.level.set_level(rand::thread_rng().gen_range(1, 4));
if npc.boss { if npc.boss {
if rand::random::<f32>() < 0.8 { if rand::random::<f32>() < 0.8 {
@ -121,7 +121,7 @@ impl<'a> System<'a> for Sys {
); );
body = comp::Body::Humanoid(comp::humanoid::Body::random()); body = comp::Body::Humanoid(comp::humanoid::Body::random());
} }
stats.level.set_level(rand::thread_rng().gen_range(20, 50)); stats.level.set_level(rand::thread_rng().gen_range(8, 15));
scale = 2.0 + rand::random::<f32>(); scale = 2.0 + rand::random::<f32>();
} }
@ -129,6 +129,13 @@ impl<'a> System<'a> for Sys {
stats stats
.health .health
.set_to(stats.health.maximum(), comp::HealthSource::Revive); .set_to(stats.health.maximum(), comp::HealthSource::Revive);
if let Some(item::Item {
kind: item::ItemKind::Tool { power, .. },
..
}) = &mut stats.equipment.main
{
*power = stats.level.level() * 3;
}
server_emitter.emit(ServerEvent::CreateNpc { server_emitter.emit(ServerEvent::CreateNpc {
pos: Pos(npc.pos), pos: Pos(npc.pos),
stats, stats,