defaults vision range in raws, only needs specifying if abnormal

This commit is contained in:
Llywelwyn 2023-09-20 20:33:05 +01:00
parent c4a87d9813
commit 954991fd9c
3 changed files with 10 additions and 41 deletions

View file

@ -14,7 +14,7 @@ pub struct Mob {
pub attacks: Option<Vec<NaturalAttack>>,
pub attributes: Option<MobAttributes>,
pub skills: Option<HashMap<String, i32>>,
pub vision_range: i32,
pub vision_range: Option<i32>,
pub telepathy_range: Option<i32>,
pub equipped: Option<Vec<String>>,
pub loot: Option<LootTableInfo>,

View file

@ -5,6 +5,7 @@ use crate::gui::Ancestry;
use crate::random_table::RandomTable;
use crate::config::CONFIG;
use crate::data::visuals::BLOODSTAIN_COLOUR;
use crate::data::entity::DEFAULT_VIEWSHED_STANDARD;
use regex::Regex;
use bracket_lib::prelude::*;
use specs::prelude::*;
@ -387,7 +388,11 @@ pub fn spawn_named_mob(
eb = eb.with(Name { name: mob_template.name.clone(), plural: mob_template.name.clone() });
eb = eb.with(Viewshed {
visible_tiles: Vec::new(),
range: mob_template.vision_range as i32,
range: if let Some(range) = mob_template.vision_range {
range
} else {
DEFAULT_VIEWSHED_STANDARD
},
dirty: true,
});
if let Some(telepath) = &mob_template.telepathy_range {