fixes message log wrapping - sort of

it's an improvement - messages will wrap if the added fragment is longer than the maximum width, but it still causes issues if an *individual* fragment is longer than the width. the proper solution here, i think, is to get rid of the whole fragment system and just log words and newlines, and not have to bother with any of this.
This commit is contained in:
Llywelwyn 2023-07-28 21:06:08 +01:00
parent 1e25d062db
commit 650afaf821
5 changed files with 48 additions and 25 deletions

View file

@ -183,6 +183,15 @@ pub fn spawn_named_mob(
) -> Option<Entity> {
if raws.mob_index.contains_key(key) {
let mob_template = &raws.raws.mobs[raws.mob_index[key]];
let mut player_level = 1;
{
let pools = ecs.read_storage::<Pools>();
let player_entity = ecs.fetch::<Entity>();
let player_pool = pools.get(*player_entity);
if let Some(pool) = player_pool {
player_level = pool.level;
}
}
let mut eb;
// New entity with a position, name, combatstats, and viewshed
@ -245,16 +254,19 @@ pub fn spawn_named_mob(
let base_mob_level = if mob_template.level.is_some() { mob_template.level.unwrap() } else { 0 };
let mut mob_level = base_mob_level;
// If the level difficulty is smaller than the mob's base level, subtract 1;
// else, if the level difficulty is larger, add one-fifth of the difference
if base_mob_level > map_difficulty {
mob_level -= 1;
} else if base_mob_level < map_difficulty {
mob_level += (map_difficulty - base_mob_level) / 5;
if mob_level as f32 > 1.5 * base_mob_level as f32 {
let mob_levelf32 = (1.5 * base_mob_level as f32).trunc();
mob_level = mob_levelf32 as i32;
}
}
// If the player is a higher level than the mob, add one-fifth of the difference
if base_mob_level < player_level {
mob_level += (player_level - base_mob_level) / 4;
}
// If the resulting mob level is more than 1.5x the base, lower it to that number
mob_level = i32::min(mob_level, (1.5 * base_mob_level as f32).trunc() as i32);
// Should really use existing RNG here
let mut rng = rltk::RandomNumberGenerator::new();
@ -265,8 +277,8 @@ pub fn spawn_named_mob(
if SPAWN_LOGGING {
rltk::console::log(format!(
"SPAWNLOG: {} ({}HP, {}MANA, {}BAC) spawned at level {} (base level: {}, map difficulty: {})",
&mob_template.name, mob_hp, mob_mana, mob_bac, mob_level, base_mob_level, map_difficulty
"SPAWNLOG: {} ({}HP, {}MANA, {}BAC) spawned at level {} ({}[base], {}[map difficulty], {}[player level])",
&mob_template.name, mob_hp, mob_mana, mob_bac, mob_level, base_mob_level, map_difficulty, player_level
));
}