diff --git a/assets/common/abilities/bow/basic.ron b/assets/common/abilities/bow/basic.ron index 8155011f63..fe15b34c37 100644 --- a/assets/common/abilities/bow/basic.ron +++ b/assets/common/abilities/bow/basic.ron @@ -12,18 +12,17 @@ BasicRanged( Knockback(Away(10.0)), RewardEnergy(50), Vanish, - /*projectile::Effect::Buff { - buff: Buff::new( - BuffKind::Bleeding, - BuffData { - strength: 20.0 * self.base_power(), - duration: Some(Duration::from_secs(5)), - }, - vec![BuffCategory::Physical], - BuffSource::Unknown, + Buff( + buff: ( + kind: Bleeding, + data: ( + strength: 20.0, + duration: Some(5), // secs + ), + cat_ids: [Physical], ), chance: Some(0.10), - },*/ + ), ], time_left: 15, // seconds owner: None, diff --git a/assets/common/abilities/bow/repeater.ron b/assets/common/abilities/bow/repeater.ron index e27dfb7dc7..143e610fac 100644 --- a/assets/common/abilities/bow/repeater.ron +++ b/assets/common/abilities/bow/repeater.ron @@ -14,18 +14,17 @@ RepeaterRanged( )), Knockback(Away(10.0)), Vanish, - /*projectile::Effect::Buff { - buff: Buff::new( - BuffKind::Bleeding, - BuffData { - strength: 20.0 * self.base_power(), - duration: Some(Duration::from_secs(5)), - }, - vec![BuffCategory::Physical], - BuffSource::Unknown, + Buff( + buff: ( + kind: Bleeding, + data: ( + strength: 20.0, + duration: Some(5), // secs + ), + cat_ids: [Physical], ), chance: Some(0.10), - },*/ + ), ], time_left: 15, // seconds owner: None, diff --git a/common/src/comp/inventory/item/tool.rs b/common/src/comp/inventory/item/tool.rs index c8797bf4d3..37a6751292 100644 --- a/common/src/comp/inventory/item/tool.rs +++ b/common/src/comp/inventory/item/tool.rs @@ -4,10 +4,10 @@ use crate::{ comp::{ body::object, - buff::{Buff, BuffCategory, BuffData, BuffKind, BuffSource}, + buff::{BuffCategory, BuffData, BuffKind}, projectile, Body, CharacterAbility, Gravity, LightEmitter, Projectile, }, - effect::Effect, + effect::{BuffEffect, Effect}, states::combo_melee, Damage, DamageSource, Explosion, GroupTarget, Knockback, RadiusEffect, }; @@ -324,15 +324,14 @@ impl Tool { projectile::Effect::RewardEnergy(50), projectile::Effect::Vanish, projectile::Effect::Buff { - buff: Buff::new( - BuffKind::Bleeding, - BuffData { + buff: BuffEffect { + kind: BuffKind::Bleeding, + data: BuffData { strength: 20.0 * self.base_power(), duration: Some(Duration::from_secs(5)), }, - vec![BuffCategory::Physical], - BuffSource::Unknown, - ), + cat_ids: vec![BuffCategory::Physical], + }, chance: Some(0.10), }, ], @@ -380,15 +379,14 @@ impl Tool { projectile::Effect::Knockback(Knockback::Away(10.0)), projectile::Effect::Vanish, projectile::Effect::Buff { - buff: Buff::new( - BuffKind::Bleeding, - BuffData { + buff: BuffEffect { + kind: BuffKind::Bleeding, + data: BuffData { strength: 20.0 * self.base_power(), duration: Some(Duration::from_secs(5)), }, - vec![BuffCategory::Physical], - BuffSource::Unknown, - ), + cat_ids: vec![BuffCategory::Physical], + }, chance: Some(0.10), }, ], diff --git a/common/src/comp/projectile.rs b/common/src/comp/projectile.rs index f24bd79b50..470135f2c5 100644 --- a/common/src/comp/projectile.rs +++ b/common/src/comp/projectile.rs @@ -1,4 +1,4 @@ -use crate::{comp::Buff, sync::Uid, Damage, Explosion, GroupTarget, Knockback}; +use crate::{effect::BuffEffect, sync::Uid, Damage, Explosion, GroupTarget, Knockback}; use serde::{Deserialize, Serialize}; use specs::{Component, FlaggedStorage}; use specs_idvs::IdvStorage; @@ -13,7 +13,10 @@ pub enum Effect { Vanish, Stick, Possess, - Buff { buff: Buff, chance: Option }, + Buff { + buff: BuffEffect, + chance: Option, + }, } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] diff --git a/common/src/states/charged_ranged.rs b/common/src/states/charged_ranged.rs index 951dac68e0..73e27ba4c6 100644 --- a/common/src/states/charged_ranged.rs +++ b/common/src/states/charged_ranged.rs @@ -1,9 +1,10 @@ use crate::{ comp::{ - buff::{Buff, BuffCategory, BuffData, BuffKind, BuffSource}, + buff::{BuffCategory, BuffData, BuffKind}, projectile, Body, CharacterState, EnergyChange, EnergySource, Gravity, LightEmitter, Projectile, StateUpdate, }, + effect::BuffEffect, event::ServerEvent, states::utils::*, sys::character_behavior::{CharacterBehavior, JoinData}, @@ -105,15 +106,14 @@ impl CharacterBehavior for Data { projectile::Effect::Knockback(Knockback::Away(knockback)), projectile::Effect::Vanish, projectile::Effect::Buff { - buff: Buff::new( - BuffKind::Bleeding, - BuffData { + buff: BuffEffect { + kind: BuffKind::Bleeding, + data: BuffData { strength: damage.value / 5.0, duration: Some(Duration::from_secs(5)), }, - vec![BuffCategory::Physical], - BuffSource::Unknown, - ), + cat_ids: vec![BuffCategory::Physical], + }, chance: Some(0.10), }, ], diff --git a/common/src/sys/projectile.rs b/common/src/sys/projectile.rs index 9e3f66b958..1ef563ab5a 100644 --- a/common/src/sys/projectile.rs +++ b/common/src/sys/projectile.rs @@ -1,6 +1,6 @@ use crate::{ comp::{ - buff::{BuffChange, BuffSource}, + buff::{Buff, BuffChange, BuffSource}, projectile, EnergyChange, EnergySource, Group, HealthSource, Loadout, Ori, PhysicsState, Pos, Projectile, Vel, }, @@ -176,10 +176,13 @@ impl<'a> System<'a> for Sys { uid_allocator.retrieve_entity_internal(other.into()) { if chance.map_or(true, |c| thread_rng().gen::() < c) { - let mut buff = buff.clone(); - if let Some(uid) = projectile.owner { - buff.source = BuffSource::Character { by: uid }; - } + let source = if let Some(owner) = projectile.owner { + BuffSource::Character { by: owner } + } else { + BuffSource::Unknown + }; + let buff = + Buff::new(buff.kind, buff.data, buff.cat_ids, source); server_emitter.emit(ServerEvent::Buff { entity, buff_change: BuffChange::Add(buff),