Increase player strength to decrease difficulty somewhat, complete section 5.25
This commit is contained in:
parent
830b721548
commit
c1b72b22a1
@ -1,10 +1,10 @@
|
|||||||
use ::rltk::Point;
|
use ::rltk::{Point, RandomNumberGenerator};
|
||||||
use ::specs::prelude::*;
|
use ::specs::prelude::*;
|
||||||
use ::specs::saveload::{MarkedBuilder, SimpleMarker};
|
use ::specs::saveload::{MarkedBuilder, SimpleMarker};
|
||||||
|
|
||||||
use super::{add_effect, entity_position, EffectSpawner, EffectType, Targets};
|
use super::{add_effect, entity_position, EffectSpawner, EffectType, Targets};
|
||||||
use crate::components::{
|
use crate::components::{
|
||||||
Attributes, Confusion, DamageOverTime, Duration, Name, Player, Pools, SerializeMe, Slow,
|
Attributes, Confusion, DamageOverTime, Duration, Name, Player, Pools, SerializeMe, Skills, Slow,
|
||||||
};
|
};
|
||||||
use crate::gamesystem::{mana_at_level, player_hp_at_level};
|
use crate::gamesystem::{mana_at_level, player_hp_at_level};
|
||||||
use crate::{colors, EquipmentChanged, GameLog, Map, StatusEffect};
|
use crate::{colors, EquipmentChanged, GameLog, Map, StatusEffect};
|
||||||
@ -54,7 +54,7 @@ pub fn death(ecs: &mut World, effect: &EffectSpawner, target: Entity) {
|
|||||||
let mut gold_gain = 0.0f32;
|
let mut gold_gain = 0.0f32;
|
||||||
|
|
||||||
let mut pools = ecs.write_storage::<Pools>();
|
let mut pools = ecs.write_storage::<Pools>();
|
||||||
let attributes = ecs.read_storage::<Attributes>();
|
let mut attributes = ecs.write_storage::<Attributes>();
|
||||||
let map = ecs.fetch::<Map>();
|
let map = ecs.fetch::<Map>();
|
||||||
|
|
||||||
if let Some(pos) = entity_position(ecs, target) {
|
if let Some(pos) = entity_position(ecs, target) {
|
||||||
@ -71,7 +71,7 @@ pub fn death(ecs: &mut World, effect: &EffectSpawner, target: Entity) {
|
|||||||
if xp_gain != 0 || gold_gain != 0.0 {
|
if xp_gain != 0 || gold_gain != 0.0 {
|
||||||
let mut log = ecs.fetch_mut::<GameLog>();
|
let mut log = ecs.fetch_mut::<GameLog>();
|
||||||
let mut player_stats = pools.get_mut(source).unwrap();
|
let mut player_stats = pools.get_mut(source).unwrap();
|
||||||
let player_attributes = attributes.get(source).unwrap();
|
let mut player_attributes = attributes.get_mut(source).unwrap();
|
||||||
player_stats.xp += xp_gain;
|
player_stats.xp += xp_gain;
|
||||||
player_stats.gold += gold_gain;
|
player_stats.gold += gold_gain;
|
||||||
if player_stats.xp >= player_stats.level * 1000 {
|
if player_stats.xp >= player_stats.level * 1000 {
|
||||||
@ -81,6 +81,39 @@ pub fn death(ecs: &mut World, effect: &EffectSpawner, target: Entity) {
|
|||||||
"Congratulations, you are now level {}",
|
"Congratulations, you are now level {}",
|
||||||
player_stats.level
|
player_stats.level
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// Improve a random attribute
|
||||||
|
let mut rng = ecs.fetch_mut::<RandomNumberGenerator>();
|
||||||
|
match rng.roll_dice(1, 4) {
|
||||||
|
1 => {
|
||||||
|
player_attributes.might.base += 1;
|
||||||
|
log.append("You feel stronger!");
|
||||||
|
}
|
||||||
|
2 => {
|
||||||
|
player_attributes.fitness.base += 1;
|
||||||
|
log.append("You feel healthier!");
|
||||||
|
}
|
||||||
|
3 => {
|
||||||
|
player_attributes.quickness.base += 1;
|
||||||
|
log.append("You feel quicker!");
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
player_attributes.intelligence.base += 1;
|
||||||
|
log.append("You feel smarter!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Improve all skills
|
||||||
|
let mut skills = ecs.write_storage::<Skills>();
|
||||||
|
let player_skills = skills.get_mut(*ecs.fetch::<Entity>()).unwrap();
|
||||||
|
for sk in player_skills.skills.iter_mut() {
|
||||||
|
*sk.1 += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ecs.write_storage::<EquipmentChanged>()
|
||||||
|
.insert(*ecs.fetch::<Entity>(), EquipmentChanged {})
|
||||||
|
.expect("Failed to insert EquipmentChanged tag");
|
||||||
|
|
||||||
player_stats.hit_points.max = player_hp_at_level(
|
player_stats.hit_points.max = player_hp_at_level(
|
||||||
player_attributes.fitness.base + player_attributes.fitness.modifiers,
|
player_attributes.fitness.base + player_attributes.fitness.modifiers,
|
||||||
player_stats.level,
|
player_stats.level,
|
||||||
|
@ -5,11 +5,11 @@ pub fn attr_bonus(value: i32) -> i32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn player_hp_per_level(fitness: i32) -> i32 {
|
pub fn player_hp_per_level(fitness: i32) -> i32 {
|
||||||
10 + attr_bonus(fitness)
|
15 + attr_bonus(fitness)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn player_hp_at_level(fitness: i32, level: i32) -> i32 {
|
pub fn player_hp_at_level(fitness: i32, level: i32) -> i32 {
|
||||||
10 + player_hp_per_level(fitness) * level
|
15 + player_hp_per_level(fitness) * level
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn npc_hp(fitness: i32, level: i32) -> i32 {
|
pub fn npc_hp(fitness: i32, level: i32) -> i32 {
|
||||||
|
Loading…
Reference in New Issue
Block a user