minor fixes, altars can heal

This commit is contained in:
Llywelwyn 2023-08-21 19:20:08 +01:00
parent fe19a449e3
commit 397aa07d60
7 changed files with 18 additions and 9 deletions

View file

@ -9,7 +9,8 @@
"id": "prop_altar",
"name": "altar",
"renderable": { "glyph": "_", "fg": "#FFFFFF", "bg": "#000000", "order": 2 },
"flags": []
"flags": ["ENTRY_TRIGGER"],
"effects": { "heal": "8d8" }
},
{
"id": "prop_keg",

View file

@ -2,6 +2,7 @@ use crate::{
raws::Reaction, Chasing, Faction, HasAncestry, Map, Mind, Position, TakingTurn, Telepath, Viewshed,
WantsToApproach, WantsToFlee,
};
use rltk::prelude::*;
use specs::prelude::*;
use std::collections::HashSet;

View file

@ -2,8 +2,8 @@ use super::{EffectSpawner, EffectType};
use crate::{HungerClock, BUC};
use specs::prelude::*;
pub fn restore_food(ecs: &mut World, effect: &EffectSpawner, target: Entity) {
if let EffectType::RestoreNutrition { amount } = &effect.effect_type {
pub fn modify_nutrition(ecs: &mut World, effect: &EffectSpawner, target: Entity) {
if let EffectType::ModifyNutrition { amount } = &effect.effect_type {
if let Some(hc) = ecs.write_storage::<HungerClock>().get_mut(target) {
hc.duration += amount;
}

View file

@ -29,7 +29,7 @@ pub enum EffectType {
Particle { glyph: FontCharType, fg: RGB, bg: RGB, lifespan: f32, delay: f32 },
EntityDeath,
ItemUse { item: Entity },
RestoreNutrition { amount: i32 },
ModifyNutrition { amount: i32 },
TriggerFire { trigger: Entity },
}
@ -116,7 +116,7 @@ fn tile_effect_hits_entities(effect: &EffectType) -> bool {
match effect {
EffectType::Damage { .. } => true,
EffectType::Healing { .. } => true,
EffectType::RestoreNutrition { .. } => true,
EffectType::ModifyNutrition { .. } => true,
EffectType::Confusion { .. } => true,
_ => false,
}
@ -139,7 +139,7 @@ fn affect_entity(ecs: &mut World, effect: &EffectSpawner, target: Entity) {
}
}
EffectType::EntityDeath => damage::entity_death(ecs, effect, target),
EffectType::RestoreNutrition { .. } => hunger::restore_food(ecs, effect, target),
EffectType::ModifyNutrition { .. } => hunger::modify_nutrition(ecs, effect, target),
_ => {}
}
}

View file

@ -87,7 +87,7 @@ fn handle_restore_nutrition(
BUC::Uncursed => 400,
BUC::Cursed => 200,
};
add_effect(event.source, EffectType::RestoreNutrition { amount }, event.target.clone());
add_effect(event.source, EffectType::ModifyNutrition { amount }, event.target.clone());
logger = logger
.append("You eat the")
.colour(item_colour_ecs(ecs, event.entity))

View file

@ -309,9 +309,12 @@ pub fn try_move_player(delta_x: i32, delta_y: i32, ecs: &mut World) -> RunState
result = crate::spatial::for_each_tile_content_with_runstate(destination_idx, |potential_target| {
let mut hostile = true;
if pools.get(potential_target).is_some() {
// We get the reaction of the target to this entity --
// i.e. in reverse to usual. We want to know if the target
// is hostile to us. If it isn't, we can swap places.
let result = crate::raws::get_reactions(
entity,
potential_target,
entity,
&factions,
&ancestries,
&crate::raws::RAWS.lock().unwrap(),

View file

@ -45,7 +45,11 @@ macro_rules! apply_flags {
"BLOCKS_VISIBILITY" => $eb = $eb.with(BlocksVisibility {}),
"ENTRY_TRIGGER" => $eb = $eb.with(EntryTrigger {}),
"SINGLE_ACTIVATION" => $eb = $eb.with(SingleActivation {}),
"DOOR" => $eb = $eb.with(Door { open: false }),
"DOOR" => {
$eb = $eb.with(Door { open: false });
$eb = $eb.with(BlocksVisibility {});
$eb = $eb.with(BlocksTile {});
}
// RESTORES NUTRITION
"FOOD" => $eb = $eb.with(ProvidesNutrition {}),
// IS DELETED ON USE