combat log to config
This commit is contained in:
parent
038e616500
commit
72ec24c6b6
2 changed files with 14 additions and 12 deletions
|
|
@ -12,6 +12,14 @@ pub struct Config {
|
||||||
pub visuals: VisualConfig,
|
pub visuals: VisualConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
pub struct LogConfig {
|
||||||
|
pub show_mapgen: bool,
|
||||||
|
pub log_combat: bool,
|
||||||
|
pub log_spawning: bool,
|
||||||
|
pub log_ticks: bool,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct VisualConfig {
|
pub struct VisualConfig {
|
||||||
pub with_scanlines: bool,
|
pub with_scanlines: bool,
|
||||||
|
|
@ -19,18 +27,12 @@ pub struct VisualConfig {
|
||||||
pub with_darken_by_distance: bool,
|
pub with_darken_by_distance: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
|
||||||
pub struct LogConfig {
|
|
||||||
pub show_mapgen: bool,
|
|
||||||
pub log_spawning: bool,
|
|
||||||
pub log_ticks: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for Config {
|
impl Default for Config {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Config {
|
Config {
|
||||||
logging: LogConfig {
|
logging: LogConfig {
|
||||||
show_mapgen: false,
|
show_mapgen: false,
|
||||||
|
log_combat: false,
|
||||||
log_spawning: false,
|
log_spawning: false,
|
||||||
log_ticks: false,
|
log_ticks: false,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ use super::{
|
||||||
ToHitBonus,
|
ToHitBonus,
|
||||||
WantsToMelee,
|
WantsToMelee,
|
||||||
WeaponAttribute,
|
WeaponAttribute,
|
||||||
|
config::CONFIG,
|
||||||
};
|
};
|
||||||
use rltk::prelude::*;
|
use rltk::prelude::*;
|
||||||
use specs::prelude::*;
|
use specs::prelude::*;
|
||||||
|
|
@ -88,7 +89,6 @@ impl<'a> System<'a> for MeleeCombatSystem {
|
||||||
// e.g. An attacker with +0 to-hit hitting a target with 0 AC:
|
// e.g. An attacker with +0 to-hit hitting a target with 0 AC:
|
||||||
// 1d20 must be less than 10, 45% chance of a hit
|
// 1d20 must be less than 10, 45% chance of a hit
|
||||||
|
|
||||||
const COMBAT_LOGGING: bool = true;
|
|
||||||
let mut logger = gamelog::Logger::new();
|
let mut logger = gamelog::Logger::new();
|
||||||
let mut something_to_log = false;
|
let mut something_to_log = false;
|
||||||
|
|
||||||
|
|
@ -210,7 +210,7 @@ impl<'a> System<'a> for MeleeCombatSystem {
|
||||||
let target_number = monster_v_player_bonus + armour_class_roll + attacker_bonuses;
|
let target_number = monster_v_player_bonus + armour_class_roll + attacker_bonuses;
|
||||||
|
|
||||||
let target_name = names.get(wants_melee.target).unwrap();
|
let target_name = names.get(wants_melee.target).unwrap();
|
||||||
if COMBAT_LOGGING {
|
if CONFIG.logging.log_combat {
|
||||||
rltk::console::log(
|
rltk::console::log(
|
||||||
format!(
|
format!(
|
||||||
"ATTACKLOG: {} *{}* {}: rolled ({}) 1d20 vs. {} ({} + {}AC + {}to-hit)",
|
"ATTACKLOG: {} *{}* {}: rolled ({}) 1d20 vs. {} ({} + {}AC + {}to-hit)",
|
||||||
|
|
@ -248,7 +248,7 @@ impl<'a> System<'a> for MeleeCombatSystem {
|
||||||
}
|
}
|
||||||
let mut damage = i32::max(0, base_damage + skill_damage_bonus + attribute_damage_bonus);
|
let mut damage = i32::max(0, base_damage + skill_damage_bonus + attribute_damage_bonus);
|
||||||
|
|
||||||
if COMBAT_LOGGING {
|
if CONFIG.logging.log_combat {
|
||||||
rltk::console::log(
|
rltk::console::log(
|
||||||
format!(
|
format!(
|
||||||
"ATTACKLOG: {} HIT for {} ({}[{}d{}]+{}[skill]+{}[attr])",
|
"ATTACKLOG: {} HIT for {} ({}[{}d{}]+{}[skill]+{}[attr])",
|
||||||
|
|
@ -266,7 +266,7 @@ impl<'a> System<'a> for MeleeCombatSystem {
|
||||||
if actual_armour_class < 0 {
|
if actual_armour_class < 0 {
|
||||||
let ac_damage_reduction = rng.roll_dice(1, -actual_armour_class);
|
let ac_damage_reduction = rng.roll_dice(1, -actual_armour_class);
|
||||||
damage = i32::min(1, damage - ac_damage_reduction);
|
damage = i32::min(1, damage - ac_damage_reduction);
|
||||||
if COMBAT_LOGGING {
|
if CONFIG.logging.log_combat {
|
||||||
rltk::console::log(
|
rltk::console::log(
|
||||||
format!(
|
format!(
|
||||||
"ATTACKLOG: {} reduced their damage taken by {} (1dAC), and took {} hp damage.",
|
"ATTACKLOG: {} reduced their damage taken by {} (1dAC), and took {} hp damage.",
|
||||||
|
|
@ -320,7 +320,7 @@ impl<'a> System<'a> for MeleeCombatSystem {
|
||||||
.log();
|
.log();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if COMBAT_LOGGING {
|
if CONFIG.logging.log_combat {
|
||||||
rltk::console::log(format!("ATTACKLOG: {} *MISSED*", &name.name));
|
rltk::console::log(format!("ATTACKLOG: {} *MISSED*", &name.name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue