Allows some species to be immune to specific buffs

This commit is contained in:
Snowram 2021-02-20 14:03:15 +00:00
parent a330d4b05c
commit f78170704a
3 changed files with 17 additions and 1 deletions

View File

@ -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 missing controller actions (dance and crafting)
- Fixed a bug where the stairs to the boss floor in dungeons would sometimes not spawn - Fixed a bug where the stairs to the boss floor in dungeons would sometimes not spawn
- Fixed waypoints being placed underwater - Fixed waypoints being placed underwater
- Objects and golems are not affected by bleed debuff anymore
## [0.8.0] - 2020-11-28 ## [0.8.0] - 2020-11-28

View File

@ -22,6 +22,8 @@ use specs::{Component, DerefFlaggedStorage};
use specs_idvs::IdvStorage; use specs_idvs::IdvStorage;
use vek::*; use vek::*;
use super::BuffKind;
make_case_elim!( make_case_elim!(
body, body,
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[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 /// Returns a multiplier representing increased difficulty not accounted for
/// due to AI or not using an actual weapon /// due to AI or not using an actual weapon
// TODO: Match on species // TODO: Match on species

View File

@ -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) { pub fn handle_buff(server: &mut Server, entity: EcsEntity, buff_change: buff::BuffChange) {
let ecs = &server.state.ecs(); let ecs = &server.state.ecs();
let mut buffs_all = ecs.write_storage::<comp::Buffs>(); let mut buffs_all = ecs.write_storage::<comp::Buffs>();
let bodies = ecs.read_storage::<comp::Body>();
if let Some(mut buffs) = buffs_all.get_mut(entity) { if let Some(mut buffs) = buffs_all.get_mut(entity) {
use buff::BuffChange; use buff::BuffChange;
match buff_change { match buff_change {
BuffChange::Add(new_buff) => { 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) => { BuffChange::RemoveById(ids) => {
for id in ids { for id in ids {