10% of bow hits cause bleed debuff

This commit is contained in:
ubruntu 2020-11-01 18:38:57 +00:00 committed by Samuel Keiffer
parent 34c3bab6ad
commit b11041dfa4
4 changed files with 62 additions and 2 deletions

View File

@ -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,

View File

@ -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<f32> },
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]

View File

@ -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,

View File

@ -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::<f32>() < 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),
});
}
}
},
_ => {},
}
}