Different body types now have different health values and gain different amounts of healths on leveling.

This commit is contained in:
Samuel Keiffer 2020-07-09 00:04:25 +00:00 committed by Joshua Barretto
parent a0df8bee2c
commit 25c28f26d6
8 changed files with 137 additions and 16 deletions

View File

@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Bombs - Bombs
- Training dummy items - Training dummy items
- Added spin attack for axe - Added spin attack for axe
- Creature specific stats
### Changed ### Changed

View File

@ -131,6 +131,81 @@ pub struct Stats {
pub fitness: u32, pub fitness: u32,
pub willpower: u32, pub willpower: u32,
pub is_dead: bool, pub is_dead: bool,
pub body_type: Body,
}
impl Body {
pub fn base_health(&self) -> u32 {
match self {
Body::Humanoid(_) => 52,
Body::QuadrupedSmall(_) => 44,
Body::QuadrupedMedium(_) => 72,
Body::BirdMedium(_) => 36,
Body::FishMedium(_) => 32,
Body::Dragon(_) => 256,
Body::BirdSmall(_) => 24,
Body::FishSmall(_) => 20,
Body::BipedLarge(_) => 144,
Body::Object(_) => 100,
Body::Golem(_) => 168,
Body::Critter(_) => 32,
Body::QuadrupedLow(_) => 64,
}
}
pub fn base_health_increase(&self) -> u32 {
match self {
Body::Humanoid(_) => 5,
Body::QuadrupedSmall(_) => 4,
Body::QuadrupedMedium(_) => 7,
Body::BirdMedium(_) => 4,
Body::FishMedium(_) => 3,
Body::Dragon(_) => 26,
Body::BirdSmall(_) => 2,
Body::FishSmall(_) => 2,
Body::BipedLarge(_) => 14,
Body::Object(_) => 0,
Body::Golem(_) => 17,
Body::Critter(_) => 3,
Body::QuadrupedLow(_) => 6,
}
}
pub fn base_exp(&self) -> u32 {
match self {
Body::Humanoid(_) => 15,
Body::QuadrupedSmall(_) => 12,
Body::QuadrupedMedium(_) => 28,
Body::BirdMedium(_) => 10,
Body::FishMedium(_) => 8,
Body::Dragon(_) => 160,
Body::BirdSmall(_) => 5,
Body::FishSmall(_) => 4,
Body::BipedLarge(_) => 75,
Body::Object(_) => 0,
Body::Golem(_) => 75,
Body::Critter(_) => 8,
Body::QuadrupedLow(_) => 24,
}
}
pub fn base_exp_increase(&self) -> u32 {
match self {
Body::Humanoid(_) => 3,
Body::QuadrupedSmall(_) => 2,
Body::QuadrupedMedium(_) => 6,
Body::BirdMedium(_) => 2,
Body::FishMedium(_) => 2,
Body::Dragon(_) => 32,
Body::BirdSmall(_) => 1,
Body::FishSmall(_) => 1,
Body::BipedLarge(_) => 15,
Body::Object(_) => 0,
Body::Golem(_) => 15,
Body::Critter(_) => 2,
Body::QuadrupedLow(_) => 5,
}
}
} }
impl Stats { impl Stats {
@ -143,7 +218,10 @@ 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) { self.health.set_maximum(52 + 3 * self.level.amount); } pub fn update_max_hp(&mut self, body: Body) {
self.health
.set_maximum(body.base_health() + body.base_health_increase() * self.level.amount);
}
} }
impl Stats { impl Stats {
@ -187,9 +265,10 @@ impl Stats {
fitness, fitness,
willpower, willpower,
is_dead: false, is_dead: false,
body_type: body,
}; };
stats.update_max_hp(); stats.update_max_hp(body);
stats stats
.health .health
.set_to(stats.health.maximum(), HealthSource::Revive); .set_to(stats.health.maximum(), HealthSource::Revive);

View File

@ -2,7 +2,7 @@ use crate::{
assets, assets,
comp::{ comp::{
item::{Item, ItemKind}, item::{Item, ItemKind},
CharacterAbility, ItemConfig, Loadout, Body, CharacterAbility, ItemConfig, Loadout,
}, },
}; };
use std::time::Duration; use std::time::Duration;
@ -24,6 +24,44 @@ use std::time::Duration;
/// ``` /// ```
pub struct LoadoutBuilder(Loadout); pub struct LoadoutBuilder(Loadout);
impl Body {
pub fn base_dmg(&self) -> u32 {
match self {
Body::Humanoid(_) => 8,
Body::QuadrupedSmall(_) => 7,
Body::QuadrupedMedium(_) => 10,
Body::BirdMedium(_) => 6,
Body::FishMedium(_) => 5,
Body::Dragon(_) => 75,
Body::BirdSmall(_) => 4,
Body::FishSmall(_) => 3,
Body::BipedLarge(_) => 30,
Body::Object(_) => 0,
Body::Golem(_) => 30,
Body::Critter(_) => 6,
Body::QuadrupedLow(_) => 9,
}
}
pub fn base_range(&self) -> f32 {
match self {
Body::Humanoid(_) => 5.0,
Body::QuadrupedSmall(_) => 4.5,
Body::QuadrupedMedium(_) => 5.5,
Body::BirdMedium(_) => 3.5,
Body::FishMedium(_) => 3.5,
Body::Dragon(_) => 12.5,
Body::BirdSmall(_) => 3.0,
Body::FishSmall(_) => 3.0,
Body::BipedLarge(_) => 10.0,
Body::Object(_) => 3.0,
Body::Golem(_) => 7.5,
Body::Critter(_) => 3.0,
Body::QuadrupedLow(_) => 4.5,
}
}
}
impl LoadoutBuilder { impl LoadoutBuilder {
#[allow(clippy::new_without_default)] // TODO: Pending review in #587 #[allow(clippy::new_without_default)] // TODO: Pending review in #587
pub fn new() -> Self { pub fn new() -> Self {
@ -63,7 +101,7 @@ impl LoadoutBuilder {
} }
/// Default animal configuration /// Default animal configuration
pub fn animal() -> Self { pub fn animal(body: Body) -> Self {
Self(Loadout { Self(Loadout {
active_item: Some(ItemConfig { active_item: Some(ItemConfig {
item: assets::load_expect_cloned("common.items.weapons.empty"), item: assets::load_expect_cloned("common.items.weapons.empty"),
@ -71,8 +109,8 @@ impl LoadoutBuilder {
energy_cost: 10, energy_cost: 10,
buildup_duration: Duration::from_millis(600), buildup_duration: Duration::from_millis(600),
recover_duration: Duration::from_millis(100), recover_duration: Duration::from_millis(100),
base_healthchange: -6, base_healthchange: -(body.base_dmg() as i32),
range: 5.0, range: body.base_range(),
max_angle: 80.0, max_angle: 80.0,
}), }),
ability2: None, ability2: None,

View File

@ -22,7 +22,7 @@ impl<'a> System<'a> for Sys {
fn run( fn run(
&mut self, &mut self,
(entities, dt, server_event_bus, character_states, mut stats,mut energies): Self::SystemData, (entities, dt, server_event_bus, character_states, mut stats, mut energies): Self::SystemData,
) { ) {
let mut server_event_emitter = server_event_bus.emitter(); let mut server_event_emitter = server_event_bus.emitter();
@ -62,7 +62,7 @@ impl<'a> System<'a> for Sys {
server_event_emitter.emit(ServerEvent::LevelUp(entity, stat.level.level())); server_event_emitter.emit(ServerEvent::LevelUp(entity, stat.level.level()));
} }
stat.update_max_hp(); stat.update_max_hp(stat.body_type);
stat.health stat.health
.set_to(stat.health.maximum(), HealthSource::LevelUp); .set_to(stat.health.maximum(), HealthSource::LevelUp);
} }

View File

@ -544,7 +544,7 @@ fn handle_spawn(
.create_npc( .create_npc(
pos, pos,
comp::Stats::new(get_npc_name(id).into(), body), comp::Stats::new(get_npc_name(id).into(), body),
LoadoutBuilder::animal().build(), LoadoutBuilder::animal(body).build(),
body, body,
) )
.with(comp::Vel(vel)) .with(comp::Vel(vel))
@ -1568,7 +1568,7 @@ fn handle_set_level(
{ {
stats.level.set_level(lvl); stats.level.set_level(lvl);
stats.update_max_hp(); stats.update_max_hp(stats.body_type);
stats stats
.health .health
.set_to(stats.health.maximum(), comp::HealthSource::LevelUp); .set_to(stats.health.maximum(), comp::HealthSource::LevelUp);

View File

@ -63,9 +63,12 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc
if let Some(attacker_stats) = stats.get_mut(attacker) { if let Some(attacker_stats) = stats.get_mut(attacker) {
// TODO: Discuss whether we should give EXP by Player // TODO: Discuss whether we should give EXP by Player
// Killing or not. // Killing or not.
attacker_stats attacker_stats.exp.change_by(
.exp (entity_stats.body_type.base_exp()
.change_by((entity_stats.level.level() * 10) as i64); + entity_stats.level.level()
* entity_stats.body_type.base_exp_increase())
as i64,
);
} }
}); });
} }

View File

@ -106,7 +106,7 @@ impl From<StatsJoinData<'_>> for comp::Stats {
base_stats.exp.set_current(data.stats.exp as u32); base_stats.exp.set_current(data.stats.exp as u32);
base_stats.update_max_hp(); base_stats.update_max_hp(base_stats.body_type);
base_stats base_stats
.health .health
.set_to(base_stats.health.maximum(), comp::HealthSource::Revive); .set_to(base_stats.health.maximum(), comp::HealthSource::Revive);

View File

@ -215,7 +215,7 @@ impl<'a> System<'a> for Sys {
head: None, head: None,
tabard: None, tabard: None,
}, },
_ => LoadoutBuilder::animal().build(), _ => LoadoutBuilder::animal(entity.body).build(),
}; };
let mut scale = entity.scale; let mut scale = entity.scale;
@ -296,7 +296,7 @@ impl<'a> System<'a> for Sys {
scale = 2.0 + rand::random::<f32>(); scale = 2.0 + rand::random::<f32>();
} }
stats.update_max_hp(); stats.update_max_hp(stats.body_type);
stats stats
.health .health