From f78170704a0b66c8a56076675d722ae5611df072 Mon Sep 17 00:00:00 2001 From: Snowram Date: Sat, 20 Feb 2021 14:03:15 +0000 Subject: [PATCH] Allows some species to be immune to specific buffs --- CHANGELOG.md | 1 + common/src/comp/body.rs | 9 +++++++++ server/src/events/entity_manipulation.rs | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f65454f9bb..019789c0c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed missing controller actions (dance and crafting) - Fixed a bug where the stairs to the boss floor in dungeons would sometimes not spawn - Fixed waypoints being placed underwater +- Objects and golems are not affected by bleed debuff anymore ## [0.8.0] - 2020-11-28 diff --git a/common/src/comp/body.rs b/common/src/comp/body.rs index 0e09c027c4..a71f9f810d 100644 --- a/common/src/comp/body.rs +++ b/common/src/comp/body.rs @@ -22,6 +22,8 @@ use specs::{Component, DerefFlaggedStorage}; use specs_idvs::IdvStorage; use vek::*; +use super::BuffKind; + make_case_elim!( body, #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] @@ -439,6 +441,13 @@ impl Body { } } + pub fn immune_to(&self, buff: BuffKind) -> bool { + match buff { + BuffKind::Bleeding => matches!(self, Body::Object(_) | Body::Golem(_)), + _ => false, + } + } + /// Returns a multiplier representing increased difficulty not accounted for /// due to AI or not using an actual weapon // TODO: Match on species diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index 9ff9c8fbe6..1ceda84abe 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -776,11 +776,17 @@ pub fn handle_aura(server: &mut Server, entity: EcsEntity, aura_change: aura::Au pub fn handle_buff(server: &mut Server, entity: EcsEntity, buff_change: buff::BuffChange) { let ecs = &server.state.ecs(); let mut buffs_all = ecs.write_storage::(); + let bodies = ecs.read_storage::(); if let Some(mut buffs) = buffs_all.get_mut(entity) { use buff::BuffChange; match buff_change { BuffChange::Add(new_buff) => { - buffs.insert(new_buff); + if !bodies + .get(entity) + .map_or(false, |body| body.immune_to(new_buff.kind)) + { + buffs.insert(new_buff); + } }, BuffChange::RemoveById(ids) => { for id in ids {