diff --git a/common/src/comp/inventory/item/tool.rs b/common/src/comp/inventory/item/tool.rs index 3b4ab95573..a097d49d9e 100644 --- a/common/src/comp/inventory/item/tool.rs +++ b/common/src/comp/inventory/item/tool.rs @@ -2,7 +2,11 @@ // version in voxygen\src\meta.rs in order to reset save files to being empty use crate::{ - comp::{body::object, projectile, Body, CharacterAbility, Gravity, LightEmitter, Projectile}, + comp::{ + body::object, + buff::{Buff, BuffCategory, BuffData, BuffKind, BuffSource}, + projectile, Body, CharacterAbility, Gravity, LightEmitter, Projectile, + }, states::combo_melee, Damage, Damages, Explosion, Knockback, }; @@ -305,6 +309,18 @@ impl Tool { projectile::Effect::Knockback(Knockback::Away(10.0)), projectile::Effect::RewardEnergy(50), projectile::Effect::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, + ), + chance: Some(0.10), + }, ], time_left: Duration::from_secs(15), owner: None, @@ -347,6 +363,18 @@ impl Tool { )), projectile::Effect::Knockback(Knockback::Away(10.0)), projectile::Effect::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, + ), + chance: Some(0.10), + }, ], time_left: Duration::from_secs(15), owner: None, diff --git a/common/src/comp/projectile.rs b/common/src/comp/projectile.rs index 3b5888a456..e90bbc94f0 100644 --- a/common/src/comp/projectile.rs +++ b/common/src/comp/projectile.rs @@ -1,4 +1,4 @@ -use crate::{sync::Uid, Damages, Explosion, Knockback}; +use crate::{comp::Buff, sync::Uid, Damages, Explosion, Knockback}; use serde::{Deserialize, Serialize}; use specs::{Component, FlaggedStorage}; use specs_idvs::IdvStorage; @@ -13,6 +13,7 @@ pub enum Effect { Vanish, Stick, Possess, + Buff { buff: Buff, 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 036f9ac5bc..32d1796527 100644 --- a/common/src/states/charged_ranged.rs +++ b/common/src/states/charged_ranged.rs @@ -1,5 +1,6 @@ use crate::{ comp::{ + buff::{Buff, BuffCategory, BuffData, BuffKind, BuffSource}, projectile, Body, CharacterState, EnergySource, Gravity, LightEmitter, Projectile, StateUpdate, }, @@ -101,6 +102,18 @@ impl CharacterBehavior for Data { )), projectile::Effect::Knockback(Knockback::Away(knockback)), projectile::Effect::Vanish, + projectile::Effect::Buff { + buff: Buff::new( + BuffKind::Bleeding, + BuffData { + strength: damage / 5.0, + duration: Some(Duration::from_secs(5)), + }, + vec![BuffCategory::Physical], + BuffSource::Unknown, + ), + chance: Some(0.10), + }, ], time_left: Duration::from_secs(15), owner: None, diff --git a/common/src/sys/projectile.rs b/common/src/sys/projectile.rs index cfae192ec9..eae08e8055 100644 --- a/common/src/sys/projectile.rs +++ b/common/src/sys/projectile.rs @@ -1,5 +1,6 @@ use crate::{ comp::{ + buff::{BuffChange, BuffSource}, projectile, Energy, EnergySource, Group, HealthSource, Loadout, Ori, PhysicsState, Pos, Projectile, Vel, }, @@ -9,6 +10,7 @@ use crate::{ state::DeltaTime, sync::UidAllocator, }; +use rand::{thread_rng, Rng}; use specs::{ saveload::MarkerAllocator, Entities, Join, Read, ReadExpect, ReadStorage, System, WriteStorage, }; @@ -155,6 +157,22 @@ impl<'a> System<'a> for Sys { } } }, + projectile::Effect::Buff { buff, chance } => { + if let Some(entity) = + 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 }; + } + server_emitter.emit(ServerEvent::Buff { + entity, + buff_change: BuffChange::Add(buff), + }); + } + } + }, _ => {}, } }