diff --git a/raws/items.json b/raws/items.json index 7bbea97..aa5eabb 100644 --- a/raws/items.json +++ b/raws/items.json @@ -7,7 +7,7 @@ "value": 50, "flags": ["CONSUMABLE", "DESTRUCTIBLE"], "effects": { "provides_healing": "2d4+2" }, - "magic": { "class": "common", "naming": "potion" } + "magic": { "class": "uncommon", "naming": "potion" } }, { "id": "potion_health_weak", @@ -17,7 +17,27 @@ "value": 25, "flags": ["CONSUMABLE", "DESTRUCTIBLE"], "effects": { "provides_healing": "1d4+2" }, - "magic": { "class": "common", "naming": "potion" } + "magic": { "class": "uncommon", "naming": "potion" } + }, + { + "id": "scroll_health", + "name": { "name": "scroll of healing word", "plural": "scrolls of healing word" }, + "renderable": { "glyph": "?", "fg": "#00FFFF", "bg": "#000000", "order": 2 }, + "weight": 0.5, + "value": 50, + "flags": ["CONSUMABLE", "DESTRUCTIBLE"], + "effects": { "ranged": "12", "provides_healing": "1d4+2" }, + "magic": { "class": "uncommon", "naming": "scroll" } + }, + { + "id": "scroll_mass_health", + "name": { "name": "scroll of mass healing word", "plural": "scrolls of mass healing word" }, + "renderable": { "glyph": "?", "fg": "#00FFFF", "bg": "#000000", "order": 2 }, + "weight": 0.5, + "value": 200, + "flags": ["CONSUMABLE", "DESTRUCTIBLE"], + "effects": { "ranged": "12", "aoe": "3", "provides_healing": "1d4+2" }, + "magic": { "class": "rare", "naming": "scroll" } }, { "id": "scroll_magicmissile", @@ -27,7 +47,17 @@ "value": 50, "flags": ["CONSUMABLE", "DESTRUCTIBLE"], "effects": { "ranged": "12", "damage": "3d4+3" }, - "magic": { "class": "common", "naming": "scroll" } + "magic": { "class": "uncommon", "naming": "scroll" } + }, + { + "id": "scroll_embers", + "name": { "name": "scroll of embers", "plural": "scrolls of embers" }, + "renderable": { "glyph": "?", "fg": "#00FFFF", "bg": "#000000", "order": 2 }, + "weight": 0.5, + "value": 100, + "flags": ["CONSUMABLE", "DESTRUCTIBLE"], + "effects": { "ranged": "10", "damage": "4d6", "aoe": "2" }, + "magic": { "class": "uncommon", "naming": "scroll" } }, { "id": "scroll_fireball", @@ -66,7 +96,7 @@ "weight": 0.5, "value": 200, "flags": ["CONSUMABLE", "DESTRUCTIBLE"], - "effects": { "ranged": "10", "aoe": "4", "confusion": "3" }, + "effects": { "ranged": "10", "aoe": "3", "confusion": "3" }, "magic": { "class": "veryrare", "naming": "scroll" } }, { diff --git a/raws/spawn_tables.json b/raws/spawn_tables.json index a7be6c2..abf2ca3 100644 --- a/raws/spawn_tables.json +++ b/raws/spawn_tables.json @@ -28,78 +28,82 @@ { "id": "potions", "table": [ - { "id": "potion_health_weak", "weight": 6, "difficulty": 1}, - { "id": "potion_health", "weight": 3, "difficulty": 1} + { "id": "potion_health_weak", "weight": 6, "difficulty": 1}, + { "id": "potion_health", "weight": 3, "difficulty": 1} ] }, { "id": "scrolls", "table": [ - { "id": "scroll_confusion", "weight": 2, "difficulty": 1}, - { "id": "scroll_magicmap_c", "weight": 2, "difficulty": 1}, - { "id": "scroll_magicmap", "weight": 2, "difficulty": 1}, - { "id": "scroll_fireball", "weight": 2, "difficulty": 2}, - { "id": "scroll_fireball_c", "weight": 2, "difficulty": 2} + { "id": "scroll_confusion", "weight": 2, "difficulty": 1}, + { "id": "scroll_magicmap_c", "weight": 2, "difficulty": 1}, + { "id": "scroll_magicmap", "weight": 2, "difficulty": 1}, + { "id": "scroll_embers", "weight": 2, "difficulty": 2}, + { "id": "scroll_health", "weight": 2, "difficulty": 2}, + { "id": "scroll_fireball", "weight": 2, "difficulty": 2}, + { "id": "scroll_fireball_c", "weight": 2, "difficulty": 2}, + { "id": "scroll_mass_health", "weight": 1, "difficulty": 2}, + { "id": "scroll_mass_confusion", "weight": 1, "difficulty": 3} ] }, { "id": "wands", "table": [ - { "id": "wand_magicmissile", "weight": 1, "difficulty": 1}, - { "id": "wand_confusion", "weight": 1, "difficulty": 1}, - { "id": "wand_digging", "weight": 1, "difficulty": 1}, - { "id": "wand_fireball", "weight": 1, "difficulty": 2} + { "id": "wand_magicmissile", "weight": 1, "difficulty": 1}, + { "id": "wand_confusion", "weight": 1, "difficulty": 1}, + { "id": "wand_digging", "weight": 1, "difficulty": 1}, + { "id": "wand_fireball", "weight": 1, "difficulty": 2} ] }, { "id": "food", "table": [ - { "id": "food_rations", "weight": 1, "difficulty": 1}, - { "id": "food_apple", "weight": 1, "difficulty": 1} + { "id": "food_rations", "weight": 1, "difficulty": 1}, + { "id": "food_apple", "weight": 1, "difficulty": 1} ] }, { "id": "mobs", "table": [ - { "id": "sheep_little", "weight": 1, "difficulty": 0}, - { "id": "chicken", "weight": 1, "difficulty": 1}, - { "id": "rat", "weight": 1, "difficulty": 1}, - { "id": "goblin", "weight": 3, "difficulty": 1}, - { "id": "kobold", "weight": 1, "difficulty": 1}, - { "id": "fox", "weight": 1, "difficulty": 1}, - { "id": "jackal", "weight": 4, "difficulty": 1}, - { "id": "deer_little", "weight": 1, "difficulty": 1}, - { "id": "zombie_kobold", "weight": 1, "difficulty": 1}, - { "id": "zombie_gnome", "weight": 1, "difficulty": 2}, - { "id": "kobold_large", "weight": 1, "difficulty": 2}, - { "id": "rat_giant", "weight": 2, "difficulty": 2}, - { "id": "coyote", "weight": 4, "difficulty": 2}, - { "id": "zombie_orc", "weight": 1, "difficulty": 3}, - { "id": "zombie_dwarf", "weight": 1, "difficulty": 3}, - { "id": "gnome", "weight": 1, "difficulty": 3}, - { "id": "spider_cave", "weight": 2, "difficulty": 3}, - { "id": "kobold_captain", "weight": 1, "difficulty": 3}, - { "id": "dog_little", "weight": 1, "difficulty": 3}, - { "id": "orc", "weight": 2, "difficulty": 3}, - { "id": "goblin_chieftain", "weight": 1, "difficulty": 3}, - { "id": "dwarf", "weight": 3, "difficulty": 4}, - { "id": "orc_hill", "weight": 1, "difficulty": 4}, - { "id": "horse_little", "weight": 2, "difficulty": 4}, - { "id": "dog", "weight": 1, "difficulty": 5}, - { "id": "wolf", "weight": 2, "difficulty": 6}, - { "id": "orc_captain", "weight": 1, "difficulty": 7}, - { "id": "dog_large", "weight": 1, "difficulty": 7}, - { "id": "horse", "weight": 2, "difficulty": 7}, - { "id": "ogre", "weight": 1, "difficulty": 7}, - { "id": "horse_large", "weight": 2, "difficulty": 9} + { "id": "sheep_little", "weight": 1, "difficulty": 0}, + { "id": "chicken", "weight": 1, "difficulty": 1}, + { "id": "rat", "weight": 1, "difficulty": 1}, + { "id": "goblin", "weight": 3, "difficulty": 1}, + { "id": "kobold", "weight": 1, "difficulty": 1}, + { "id": "fox", "weight": 1, "difficulty": 1}, + { "id": "jackal", "weight": 4, "difficulty": 1}, + { "id": "deer_little", "weight": 1, "difficulty": 1}, + { "id": "zombie_kobold", "weight": 1, "difficulty": 1}, + { "id": "zombie_gnome", "weight": 1, "difficulty": 2}, + { "id": "kobold_large", "weight": 1, "difficulty": 2}, + { "id": "rat_giant", "weight": 2, "difficulty": 2}, + { "id": "coyote", "weight": 4, "difficulty": 2}, + { "id": "zombie_orc", "weight": 1, "difficulty": 3}, + { "id": "zombie_dwarf", "weight": 1, "difficulty": 3}, + { "id": "gnome", "weight": 1, "difficulty": 3}, + { "id": "spider_cave", "weight": 2, "difficulty": 3}, + { "id": "kobold_captain", "weight": 1, "difficulty": 3}, + { "id": "dog_little", "weight": 1, "difficulty": 3}, + { "id": "orc", "weight": 2, "difficulty": 3}, + { "id": "goblin_chieftain", "weight": 1, "difficulty": 3}, + { "id": "dwarf", "weight": 3, "difficulty": 4}, + { "id": "orc_hill", "weight": 1, "difficulty": 4}, + { "id": "horse_little", "weight": 2, "difficulty": 4}, + { "id": "dog", "weight": 1, "difficulty": 5}, + { "id": "wolf", "weight": 2, "difficulty": 6}, + { "id": "orc_captain", "weight": 1, "difficulty": 7}, + { "id": "dog_large", "weight": 1, "difficulty": 7}, + { "id": "horse", "weight": 2, "difficulty": 7}, + { "id": "ogre", "weight": 1, "difficulty": 7}, + { "id": "horse_large", "weight": 2, "difficulty": 9} ] }, { "id": "traps", "table": [ - { "id": "trap_bear", "weight": 2, "difficulty": 1}, - { "id": "trap_confusion", "weight": 1, "difficulty": 1}, - { "id": "trap_stonefall", "weight": 1, "difficulty": 5} + { "id": "trap_bear", "weight": 2, "difficulty": 1}, + { "id": "trap_confusion", "weight": 1, "difficulty": 1}, + { "id": "trap_stonefall", "weight": 1, "difficulty": 5} ] } ] diff --git a/src/effects/triggers.rs b/src/effects/triggers.rs index 3367bc2..16f175e 100644 --- a/src/effects/triggers.rs +++ b/src/effects/triggers.rs @@ -1,7 +1,8 @@ use super::{add_effect, spatial, EffectType, Entity, Targets, World}; use crate::{ - gamelog, gui::item_colour_ecs, gui::obfuscate_name_ecs, Confusion, Consumable, Cursed, InflictsDamage, MagicMapper, - Prop, ProvidesHealing, ProvidesNutrition, RandomNumberGenerator, Renderable, RunState, + gamelog, gui::item_colour_ecs, gui::obfuscate_name_ecs, gui::renderable_colour, Confusion, Consumable, Cursed, + InflictsDamage, MagicMapper, Player, Prop, ProvidesHealing, ProvidesNutrition, RandomNumberGenerator, Renderable, + RunState, }; use rltk::prelude::*; use specs::prelude::*; @@ -85,8 +86,28 @@ fn handle_healing(ecs: &mut World, event: &mut EventInfo, mut logger: gamelog::L let mut rng = ecs.write_resource::(); let roll = rng.roll_dice(healing_item.n_dice, healing_item.sides) + healing_item.modifier; add_effect(event.source, EffectType::Healing { amount: roll }, event.target.clone()); - logger = logger.append("You recover some vigour.").buc(event.buc, None, Some("You feel great!")); - event.log = true; + for target in get_entity_targets(&event.target) { + if ecs.read_storage::().get(target).is_some() { + continue; + } + let renderables = ecs.read_storage::(); + if ecs.read_storage::().get(target).is_some() { + logger = logger + .colour(renderable_colour(&renderables, target)) + .append("You") + .colour(WHITE) + .append("recover some vigour.") + .buc(event.buc, None, Some("You feel great!")); + } else { + logger = logger + .append("The") + .colour(renderable_colour(&renderables, target)) + .append(obfuscate_name_ecs(ecs, target).0) + .colour(WHITE) + .append("is rejuvenated!"); + } + event.log = true; + } } return logger; } @@ -100,17 +121,21 @@ fn handle_damage(ecs: &mut World, event: &mut EventInfo, mut logger: gamelog::Lo if ecs.read_storage::().get(target).is_some() { continue; } - let fg = if let Some(renderable) = ecs.read_storage::().get(target) { - ((renderable.fg.r * 255.0) as u8, (renderable.fg.g * 255.0) as u8, (renderable.fg.b * 255.0) as u8) + let renderables = ecs.read_storage::(); + if ecs.read_storage::().get(target).is_some() { + logger = logger + .colour(renderable_colour(&renderables, target)) + .append(obfuscate_name_ecs(ecs, target).0) + .colour(WHITE) + .append("are hit!"); } else { - WHITE - }; - logger = logger - .append("The") - .colour(fg) - .append(obfuscate_name_ecs(ecs, target).0) - .colour(WHITE) - .append("is hit!"); + logger = logger + .append("The") + .colour(renderable_colour(&renderables, target)) + .append(obfuscate_name_ecs(ecs, target).0) + .colour(WHITE) + .append("is hit!"); + } event.log = true; } } diff --git a/src/spawner.rs b/src/spawner.rs index 9fd8dec..238d802 100644 --- a/src/spawner.rs +++ b/src/spawner.rs @@ -94,7 +94,14 @@ pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity { raws::spawn_named_entity( &raws::RAWS.lock().unwrap(), ecs, - "scroll_mass_confusion", + "scroll_mass_health", + raws::SpawnType::Carried { by: player }, + 0, + ); + raws::spawn_named_entity( + &raws::RAWS.lock().unwrap(), + ecs, + "scroll_mass_health", raws::SpawnType::Carried { by: player }, 0, );