From 6d795b6ecda5b76fad985c54f22ce6b603e1211d Mon Sep 17 00:00:00 2001 From: ubruntu Date: Tue, 22 Feb 2022 09:23:07 +0000 Subject: [PATCH] Campfire heals pets when owner sits --- common/systems/src/aura.rs | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/common/systems/src/aura.rs b/common/systems/src/aura.rs index dccd642e30..e7ce38d260 100644 --- a/common/systems/src/aura.rs +++ b/common/systems/src/aura.rs @@ -163,12 +163,28 @@ fn activate_aura( let should_activate = match aura.aura_kind { AuraKind::Buff { kind, source, .. } => { let conditions_held = match kind { - BuffKind::CampfireHeal => read_data - .char_states - .get(target) - .map_or(false, |target_state| { - target_state.is_sitting() && health.current() < health.maximum() - }), + BuffKind::CampfireHeal => { + // true if sitting or if owned and owner is sitting + not full health + health.current() < health.maximum() + && (read_data + .char_states + .get(target) + .map_or(false, CharacterState::is_sitting) + || read_data + .alignments + .get(target) + .and_then(|alignment| match alignment { + Alignment::Owned(uid) => Some(uid), + _ => None, + }) + .and_then(|uid| { + read_data + .uid_allocator + .retrieve_entity_internal((*uid).into()) + }) + .and_then(|owner| read_data.char_states.get(owner)) + .map_or(false, CharacterState::is_sitting)) + }, // Add other specific buff conditions here _ => true, };