mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
10% of bow hits cause bleed debuff
This commit is contained in:
parent
34c3bab6ad
commit
b11041dfa4
common/src
@ -2,7 +2,11 @@
|
|||||||
// version in voxygen\src\meta.rs in order to reset save files to being empty
|
// version in voxygen\src\meta.rs in order to reset save files to being empty
|
||||||
|
|
||||||
use crate::{
|
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,
|
states::combo_melee,
|
||||||
Damage, Damages, Explosion, Knockback,
|
Damage, Damages, Explosion, Knockback,
|
||||||
};
|
};
|
||||||
@ -305,6 +309,18 @@ impl Tool {
|
|||||||
projectile::Effect::Knockback(Knockback::Away(10.0)),
|
projectile::Effect::Knockback(Knockback::Away(10.0)),
|
||||||
projectile::Effect::RewardEnergy(50),
|
projectile::Effect::RewardEnergy(50),
|
||||||
projectile::Effect::Vanish,
|
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),
|
time_left: Duration::from_secs(15),
|
||||||
owner: None,
|
owner: None,
|
||||||
@ -347,6 +363,18 @@ impl Tool {
|
|||||||
)),
|
)),
|
||||||
projectile::Effect::Knockback(Knockback::Away(10.0)),
|
projectile::Effect::Knockback(Knockback::Away(10.0)),
|
||||||
projectile::Effect::Vanish,
|
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),
|
time_left: Duration::from_secs(15),
|
||||||
owner: None,
|
owner: None,
|
||||||
|
@ -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 serde::{Deserialize, Serialize};
|
||||||
use specs::{Component, FlaggedStorage};
|
use specs::{Component, FlaggedStorage};
|
||||||
use specs_idvs::IdvStorage;
|
use specs_idvs::IdvStorage;
|
||||||
@ -13,6 +13,7 @@ pub enum Effect {
|
|||||||
Vanish,
|
Vanish,
|
||||||
Stick,
|
Stick,
|
||||||
Possess,
|
Possess,
|
||||||
|
Buff { buff: Buff, chance: Option<f32> },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
comp::{
|
comp::{
|
||||||
|
buff::{Buff, BuffCategory, BuffData, BuffKind, BuffSource},
|
||||||
projectile, Body, CharacterState, EnergySource, Gravity, LightEmitter, Projectile,
|
projectile, Body, CharacterState, EnergySource, Gravity, LightEmitter, Projectile,
|
||||||
StateUpdate,
|
StateUpdate,
|
||||||
},
|
},
|
||||||
@ -101,6 +102,18 @@ impl CharacterBehavior for Data {
|
|||||||
)),
|
)),
|
||||||
projectile::Effect::Knockback(Knockback::Away(knockback)),
|
projectile::Effect::Knockback(Knockback::Away(knockback)),
|
||||||
projectile::Effect::Vanish,
|
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),
|
time_left: Duration::from_secs(15),
|
||||||
owner: None,
|
owner: None,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
comp::{
|
comp::{
|
||||||
|
buff::{BuffChange, BuffSource},
|
||||||
projectile, Energy, EnergySource, Group, HealthSource, Loadout, Ori, PhysicsState, Pos,
|
projectile, Energy, EnergySource, Group, HealthSource, Loadout, Ori, PhysicsState, Pos,
|
||||||
Projectile, Vel,
|
Projectile, Vel,
|
||||||
},
|
},
|
||||||
@ -9,6 +10,7 @@ use crate::{
|
|||||||
state::DeltaTime,
|
state::DeltaTime,
|
||||||
sync::UidAllocator,
|
sync::UidAllocator,
|
||||||
};
|
};
|
||||||
|
use rand::{thread_rng, Rng};
|
||||||
use specs::{
|
use specs::{
|
||||||
saveload::MarkerAllocator, Entities, Join, Read, ReadExpect, ReadStorage, System, WriteStorage,
|
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),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
_ => {},
|
_ => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user