more scrolls

This commit is contained in:
Llywelwyn 2023-08-17 08:34:51 +01:00
parent 03ae8992f6
commit f5394f10ab
4 changed files with 132 additions and 66 deletions

View file

@ -7,7 +7,7 @@
"value": 50, "value": 50,
"flags": ["CONSUMABLE", "DESTRUCTIBLE"], "flags": ["CONSUMABLE", "DESTRUCTIBLE"],
"effects": { "provides_healing": "2d4+2" }, "effects": { "provides_healing": "2d4+2" },
"magic": { "class": "common", "naming": "potion" } "magic": { "class": "uncommon", "naming": "potion" }
}, },
{ {
"id": "potion_health_weak", "id": "potion_health_weak",
@ -17,7 +17,27 @@
"value": 25, "value": 25,
"flags": ["CONSUMABLE", "DESTRUCTIBLE"], "flags": ["CONSUMABLE", "DESTRUCTIBLE"],
"effects": { "provides_healing": "1d4+2" }, "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", "id": "scroll_magicmissile",
@ -27,7 +47,17 @@
"value": 50, "value": 50,
"flags": ["CONSUMABLE", "DESTRUCTIBLE"], "flags": ["CONSUMABLE", "DESTRUCTIBLE"],
"effects": { "ranged": "12", "damage": "3d4+3" }, "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", "id": "scroll_fireball",
@ -66,7 +96,7 @@
"weight": 0.5, "weight": 0.5,
"value": 200, "value": 200,
"flags": ["CONSUMABLE", "DESTRUCTIBLE"], "flags": ["CONSUMABLE", "DESTRUCTIBLE"],
"effects": { "ranged": "10", "aoe": "4", "confusion": "3" }, "effects": { "ranged": "10", "aoe": "3", "confusion": "3" },
"magic": { "class": "veryrare", "naming": "scroll" } "magic": { "class": "veryrare", "naming": "scroll" }
}, },
{ {

View file

@ -28,78 +28,82 @@
{ {
"id": "potions", "id": "potions",
"table": [ "table": [
{ "id": "potion_health_weak", "weight": 6, "difficulty": 1}, { "id": "potion_health_weak", "weight": 6, "difficulty": 1},
{ "id": "potion_health", "weight": 3, "difficulty": 1} { "id": "potion_health", "weight": 3, "difficulty": 1}
] ]
}, },
{ {
"id": "scrolls", "id": "scrolls",
"table": [ "table": [
{ "id": "scroll_confusion", "weight": 2, "difficulty": 1}, { "id": "scroll_confusion", "weight": 2, "difficulty": 1},
{ "id": "scroll_magicmap_c", "weight": 2, "difficulty": 1}, { "id": "scroll_magicmap_c", "weight": 2, "difficulty": 1},
{ "id": "scroll_magicmap", "weight": 2, "difficulty": 1}, { "id": "scroll_magicmap", "weight": 2, "difficulty": 1},
{ "id": "scroll_fireball", "weight": 2, "difficulty": 2}, { "id": "scroll_embers", "weight": 2, "difficulty": 2},
{ "id": "scroll_fireball_c", "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", "id": "wands",
"table": [ "table": [
{ "id": "wand_magicmissile", "weight": 1, "difficulty": 1}, { "id": "wand_magicmissile", "weight": 1, "difficulty": 1},
{ "id": "wand_confusion", "weight": 1, "difficulty": 1}, { "id": "wand_confusion", "weight": 1, "difficulty": 1},
{ "id": "wand_digging", "weight": 1, "difficulty": 1}, { "id": "wand_digging", "weight": 1, "difficulty": 1},
{ "id": "wand_fireball", "weight": 1, "difficulty": 2} { "id": "wand_fireball", "weight": 1, "difficulty": 2}
] ]
}, },
{ {
"id": "food", "id": "food",
"table": [ "table": [
{ "id": "food_rations", "weight": 1, "difficulty": 1}, { "id": "food_rations", "weight": 1, "difficulty": 1},
{ "id": "food_apple", "weight": 1, "difficulty": 1} { "id": "food_apple", "weight": 1, "difficulty": 1}
] ]
}, },
{ {
"id": "mobs", "id": "mobs",
"table": [ "table": [
{ "id": "sheep_little", "weight": 1, "difficulty": 0}, { "id": "sheep_little", "weight": 1, "difficulty": 0},
{ "id": "chicken", "weight": 1, "difficulty": 1}, { "id": "chicken", "weight": 1, "difficulty": 1},
{ "id": "rat", "weight": 1, "difficulty": 1}, { "id": "rat", "weight": 1, "difficulty": 1},
{ "id": "goblin", "weight": 3, "difficulty": 1}, { "id": "goblin", "weight": 3, "difficulty": 1},
{ "id": "kobold", "weight": 1, "difficulty": 1}, { "id": "kobold", "weight": 1, "difficulty": 1},
{ "id": "fox", "weight": 1, "difficulty": 1}, { "id": "fox", "weight": 1, "difficulty": 1},
{ "id": "jackal", "weight": 4, "difficulty": 1}, { "id": "jackal", "weight": 4, "difficulty": 1},
{ "id": "deer_little", "weight": 1, "difficulty": 1}, { "id": "deer_little", "weight": 1, "difficulty": 1},
{ "id": "zombie_kobold", "weight": 1, "difficulty": 1}, { "id": "zombie_kobold", "weight": 1, "difficulty": 1},
{ "id": "zombie_gnome", "weight": 1, "difficulty": 2}, { "id": "zombie_gnome", "weight": 1, "difficulty": 2},
{ "id": "kobold_large", "weight": 1, "difficulty": 2}, { "id": "kobold_large", "weight": 1, "difficulty": 2},
{ "id": "rat_giant", "weight": 2, "difficulty": 2}, { "id": "rat_giant", "weight": 2, "difficulty": 2},
{ "id": "coyote", "weight": 4, "difficulty": 2}, { "id": "coyote", "weight": 4, "difficulty": 2},
{ "id": "zombie_orc", "weight": 1, "difficulty": 3}, { "id": "zombie_orc", "weight": 1, "difficulty": 3},
{ "id": "zombie_dwarf", "weight": 1, "difficulty": 3}, { "id": "zombie_dwarf", "weight": 1, "difficulty": 3},
{ "id": "gnome", "weight": 1, "difficulty": 3}, { "id": "gnome", "weight": 1, "difficulty": 3},
{ "id": "spider_cave", "weight": 2, "difficulty": 3}, { "id": "spider_cave", "weight": 2, "difficulty": 3},
{ "id": "kobold_captain", "weight": 1, "difficulty": 3}, { "id": "kobold_captain", "weight": 1, "difficulty": 3},
{ "id": "dog_little", "weight": 1, "difficulty": 3}, { "id": "dog_little", "weight": 1, "difficulty": 3},
{ "id": "orc", "weight": 2, "difficulty": 3}, { "id": "orc", "weight": 2, "difficulty": 3},
{ "id": "goblin_chieftain", "weight": 1, "difficulty": 3}, { "id": "goblin_chieftain", "weight": 1, "difficulty": 3},
{ "id": "dwarf", "weight": 3, "difficulty": 4}, { "id": "dwarf", "weight": 3, "difficulty": 4},
{ "id": "orc_hill", "weight": 1, "difficulty": 4}, { "id": "orc_hill", "weight": 1, "difficulty": 4},
{ "id": "horse_little", "weight": 2, "difficulty": 4}, { "id": "horse_little", "weight": 2, "difficulty": 4},
{ "id": "dog", "weight": 1, "difficulty": 5}, { "id": "dog", "weight": 1, "difficulty": 5},
{ "id": "wolf", "weight": 2, "difficulty": 6}, { "id": "wolf", "weight": 2, "difficulty": 6},
{ "id": "orc_captain", "weight": 1, "difficulty": 7}, { "id": "orc_captain", "weight": 1, "difficulty": 7},
{ "id": "dog_large", "weight": 1, "difficulty": 7}, { "id": "dog_large", "weight": 1, "difficulty": 7},
{ "id": "horse", "weight": 2, "difficulty": 7}, { "id": "horse", "weight": 2, "difficulty": 7},
{ "id": "ogre", "weight": 1, "difficulty": 7}, { "id": "ogre", "weight": 1, "difficulty": 7},
{ "id": "horse_large", "weight": 2, "difficulty": 9} { "id": "horse_large", "weight": 2, "difficulty": 9}
] ]
}, },
{ {
"id": "traps", "id": "traps",
"table": [ "table": [
{ "id": "trap_bear", "weight": 2, "difficulty": 1}, { "id": "trap_bear", "weight": 2, "difficulty": 1},
{ "id": "trap_confusion", "weight": 1, "difficulty": 1}, { "id": "trap_confusion", "weight": 1, "difficulty": 1},
{ "id": "trap_stonefall", "weight": 1, "difficulty": 5} { "id": "trap_stonefall", "weight": 1, "difficulty": 5}
] ]
} }
] ]

View file

@ -1,7 +1,8 @@
use super::{add_effect, spatial, EffectType, Entity, Targets, World}; use super::{add_effect, spatial, EffectType, Entity, Targets, World};
use crate::{ use crate::{
gamelog, gui::item_colour_ecs, gui::obfuscate_name_ecs, Confusion, Consumable, Cursed, InflictsDamage, MagicMapper, gamelog, gui::item_colour_ecs, gui::obfuscate_name_ecs, gui::renderable_colour, Confusion, Consumable, Cursed,
Prop, ProvidesHealing, ProvidesNutrition, RandomNumberGenerator, Renderable, RunState, InflictsDamage, MagicMapper, Player, Prop, ProvidesHealing, ProvidesNutrition, RandomNumberGenerator, Renderable,
RunState,
}; };
use rltk::prelude::*; use rltk::prelude::*;
use specs::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::<RandomNumberGenerator>(); let mut rng = ecs.write_resource::<RandomNumberGenerator>();
let roll = rng.roll_dice(healing_item.n_dice, healing_item.sides) + healing_item.modifier; 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()); 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!")); for target in get_entity_targets(&event.target) {
event.log = true; if ecs.read_storage::<Prop>().get(target).is_some() {
continue;
}
let renderables = ecs.read_storage::<Renderable>();
if ecs.read_storage::<Player>().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; return logger;
} }
@ -100,17 +121,21 @@ fn handle_damage(ecs: &mut World, event: &mut EventInfo, mut logger: gamelog::Lo
if ecs.read_storage::<Prop>().get(target).is_some() { if ecs.read_storage::<Prop>().get(target).is_some() {
continue; continue;
} }
let fg = if let Some(renderable) = ecs.read_storage::<Renderable>().get(target) { let renderables = ecs.read_storage::<Renderable>();
((renderable.fg.r * 255.0) as u8, (renderable.fg.g * 255.0) as u8, (renderable.fg.b * 255.0) as u8) if ecs.read_storage::<Player>().get(target).is_some() {
logger = logger
.colour(renderable_colour(&renderables, target))
.append(obfuscate_name_ecs(ecs, target).0)
.colour(WHITE)
.append("are hit!");
} else { } else {
WHITE logger = logger
}; .append("The")
logger = logger .colour(renderable_colour(&renderables, target))
.append("The") .append(obfuscate_name_ecs(ecs, target).0)
.colour(fg) .colour(WHITE)
.append(obfuscate_name_ecs(ecs, target).0) .append("is hit!");
.colour(WHITE) }
.append("is hit!");
event.log = true; event.log = true;
} }
} }

View file

@ -94,7 +94,14 @@ pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {
raws::spawn_named_entity( raws::spawn_named_entity(
&raws::RAWS.lock().unwrap(), &raws::RAWS.lock().unwrap(),
ecs, 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 }, raws::SpawnType::Carried { by: player },
0, 0,
); );