small tweaks, cleanup, and cranks offset
This commit is contained in:
parent
6eab48e616
commit
72f8dbbdf4
6 changed files with 22 additions and 8 deletions
|
|
@ -27,6 +27,7 @@ pub fn inflict_damage(ecs: &mut World, damage: &EffectSpawner, target: Entity) {
|
|||
Targets::Entity { target },
|
||||
);
|
||||
if target_pool.hit_points.current < 1 {
|
||||
super::DEAD_ENTITIES.lock().unwrap().push_back(target);
|
||||
add_effect(damage.source, EffectType::EntityDeath, Targets::Entity { target });
|
||||
}
|
||||
}
|
||||
|
|
@ -106,7 +107,6 @@ pub fn bloodstain(ecs: &mut World, target: usize) {
|
|||
}
|
||||
|
||||
pub fn entity_death(ecs: &mut World, effect: &EffectSpawner, target: Entity) {
|
||||
super::DEAD_ENTITIES.lock().unwrap().push_back(target);
|
||||
let mut xp_gain = 0;
|
||||
let mut pools = ecs.write_storage::<Pools>();
|
||||
let attributes = ecs.read_storage::<Attributes>();
|
||||
|
|
|
|||
|
|
@ -43,12 +43,9 @@ fn spawn_random_mob_in_free_nonvisible_tile(ecs: &mut World) {
|
|||
}
|
||||
let mut spawn_locations: Vec<(i32, i32)> = Vec::new();
|
||||
let mut rng = ecs.write_resource::<RandomNumberGenerator>();
|
||||
// Get mob type
|
||||
let key = spawner::mob_table(difficulty).roll(&mut rng);
|
||||
// Check if it spawns in a group, and roll for how many to spawn accordingly.
|
||||
let spawn_type = raws::get_mob_spawn_type(&raws::RAWS.lock().unwrap(), &key);
|
||||
let roll = raws::get_mob_spawn_amount(&mut rng, &spawn_type, player_level);
|
||||
// Get that many idxs, and push them to the spawn list.
|
||||
for _i in 0..roll {
|
||||
let idx = get_random_idx_from_tiles(&mut rng, &mut available_tiles);
|
||||
spawn_locations.push((idx as i32 % map.width, idx as i32 / map.width));
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ impl Map {
|
|||
view_blocked: HashSet::new(),
|
||||
};
|
||||
|
||||
const OFFSET_PERCENT: i32 = 10;
|
||||
const OFFSET_PERCENT: i32 = 20;
|
||||
const TWICE_OFFSET: i32 = OFFSET_PERCENT * 2;
|
||||
let mut rng = rltk::RandomNumberGenerator::new();
|
||||
|
||||
|
|
|
|||
|
|
@ -68,8 +68,8 @@ macro_rules! impl_ParseJson {
|
|||
$(impl ParseJson for $t {
|
||||
fn parse_raws_into_vector(path: String) -> $t {
|
||||
let raw_data = rltk::embedding::EMBED.lock().get_resource(path).unwrap();
|
||||
let raw_string = std::str::from_utf8(&raw_data).expect("Unable to convert to a valid UTF-8 string.");
|
||||
return serde_json::from_str(&raw_string).expect("Unable to parse items.json");
|
||||
let raw_string = std::str::from_utf8(&raw_data).expect("Failed to convert UTF-8 to &str.");
|
||||
return serde_json::from_str(&raw_string).expect("Failed to convert &str to json");
|
||||
}
|
||||
})*
|
||||
}
|
||||
|
|
|
|||
|
|
@ -697,6 +697,8 @@ pub enum SpawnsAs {
|
|||
LargeGroup,
|
||||
}
|
||||
|
||||
/// Looks up a key in the mob index, and if a corresponding mob is found, searches the
|
||||
/// entry for a group spawn flag. i.e. SMALL_GROUP/LARGE_GROUP.
|
||||
pub fn get_mob_spawn_type(raws: &RawMaster, key: &str) -> SpawnsAs {
|
||||
if raws.mob_index.contains_key(key) {
|
||||
let mob_template = &raws.raws.mobs[raws.mob_index[key]];
|
||||
|
|
|
|||
|
|
@ -101,7 +101,21 @@ pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {
|
|||
raws::spawn_named_entity(
|
||||
&raws::RAWS.lock().unwrap(),
|
||||
ecs,
|
||||
"scroll_mass_health",
|
||||
"wand_fireball",
|
||||
raws::SpawnType::Carried { by: player },
|
||||
0,
|
||||
);
|
||||
raws::spawn_named_entity(
|
||||
&raws::RAWS.lock().unwrap(),
|
||||
ecs,
|
||||
"wand_fireball",
|
||||
raws::SpawnType::Carried { by: player },
|
||||
0,
|
||||
);
|
||||
raws::spawn_named_entity(
|
||||
&raws::RAWS.lock().unwrap(),
|
||||
ecs,
|
||||
"wand_confusion",
|
||||
raws::SpawnType::Carried { by: player },
|
||||
0,
|
||||
);
|
||||
|
|
@ -266,6 +280,7 @@ pub fn food_table(difficulty: i32) -> RandomTable {
|
|||
raws::table_by_name(&raws::RAWS.lock().unwrap(), "food", difficulty)
|
||||
}
|
||||
|
||||
/// Locks RAWS, and provides access to master list of all mobs.
|
||||
pub fn mob_table(difficulty: i32) -> RandomTable {
|
||||
raws::table_by_name(&raws::RAWS.lock().unwrap(), "mobs", difficulty)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue