mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Attack effects can now have requirements.
This commit is contained in:
parent
c77f263cd1
commit
46dbb8aef4
@ -137,6 +137,10 @@ impl Attack {
|
|||||||
.filter(|e| e.target.map_or(true, |t| t == target_group))
|
.filter(|e| e.target.map_or(true, |t| t == target_group))
|
||||||
.filter(|e| !(matches!(e.target, Some(GroupTarget::OutOfGroup)) && target_dodging))
|
.filter(|e| !(matches!(e.target, Some(GroupTarget::OutOfGroup)) && target_dodging))
|
||||||
{
|
{
|
||||||
|
if match &effect.requirement {
|
||||||
|
Some(CombatRequirement::AnyDamage) => accumulated_damage != 0.0,
|
||||||
|
None => true,
|
||||||
|
} {
|
||||||
match effect.effect {
|
match effect.effect {
|
||||||
AttackEffect::Knockback(kb) => {
|
AttackEffect::Knockback(kb) => {
|
||||||
let impulse = kb.calculate_impulse(dir);
|
let impulse = kb.calculate_impulse(dir);
|
||||||
@ -168,6 +172,7 @@ impl Attack {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
server_events
|
server_events
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,11 +203,21 @@ impl DamageComponent {
|
|||||||
pub struct EffectComponent {
|
pub struct EffectComponent {
|
||||||
target: Option<GroupTarget>,
|
target: Option<GroupTarget>,
|
||||||
effect: AttackEffect,
|
effect: AttackEffect,
|
||||||
|
requirement: Option<CombatRequirement>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EffectComponent {
|
impl EffectComponent {
|
||||||
pub fn new(target: Option<GroupTarget>, effect: AttackEffect) -> Self {
|
pub fn new(target: Option<GroupTarget>, effect: AttackEffect) -> Self {
|
||||||
Self { target, effect }
|
Self {
|
||||||
|
target,
|
||||||
|
effect,
|
||||||
|
requirement: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_requirement(mut self, requirement: CombatRequirement) -> Self {
|
||||||
|
self.requirement = Some(requirement);
|
||||||
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,6 +230,11 @@ pub enum AttackEffect {
|
|||||||
//Lifesteal(f32),
|
//Lifesteal(f32),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
pub enum CombatRequirement {
|
||||||
|
AnyDamage,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
|
||||||
pub enum DamageSource {
|
pub enum DamageSource {
|
||||||
Buff(BuffKind),
|
Buff(BuffKind),
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
combat::{Attack, AttackEffect, CombatBuff, DamageComponent},
|
combat::{
|
||||||
|
Attack, AttackEffect, CombatBuff, CombatRequirement, DamageComponent, EffectComponent,
|
||||||
|
},
|
||||||
comp::{CharacterState, MeleeAttack, PoiseChange, PoiseSource, StateUpdate},
|
comp::{CharacterState, MeleeAttack, PoiseChange, PoiseSource, StateUpdate},
|
||||||
states::{
|
states::{
|
||||||
behavior::{CharacterBehavior, JoinData},
|
behavior::{CharacterBehavior, JoinData},
|
||||||
@ -99,12 +101,16 @@ impl CharacterBehavior for Data {
|
|||||||
direction: KnockbackDir::Away,
|
direction: KnockbackDir::Away,
|
||||||
});
|
});
|
||||||
let energy = AttackEffect::EnergyReward(50);
|
let energy = AttackEffect::EnergyReward(50);
|
||||||
|
let energy = EffectComponent::new(None, energy)
|
||||||
|
.with_requirement(CombatRequirement::AnyDamage);
|
||||||
let buff = AttackEffect::Buff(CombatBuff::default_melee());
|
let buff = AttackEffect::Buff(CombatBuff::default_melee());
|
||||||
let damage = DamageComponent::new(damage, Some(GroupTarget::OutOfGroup))
|
let damage = DamageComponent::new(damage, Some(GroupTarget::OutOfGroup))
|
||||||
.with_effect(knockback)
|
.with_effect(knockback)
|
||||||
.with_effect(energy)
|
|
||||||
.with_effect(buff);
|
.with_effect(buff);
|
||||||
let attack = Attack::default().with_damage(damage).with_crit(0.5, 1.3);
|
let attack = Attack::default()
|
||||||
|
.with_damage(damage)
|
||||||
|
.with_crit(0.5, 1.3)
|
||||||
|
.with_effect(energy);
|
||||||
|
|
||||||
// Hit attempt
|
// Hit attempt
|
||||||
data.updater.insert(data.entity, MeleeAttack {
|
data.updater.insert(data.entity, MeleeAttack {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
combat::{Attack, AttackEffect, CombatBuff, DamageComponent},
|
combat::{
|
||||||
|
Attack, AttackEffect, CombatBuff, CombatRequirement, DamageComponent, EffectComponent,
|
||||||
|
},
|
||||||
comp::{
|
comp::{
|
||||||
CharacterState, EnergyChange, EnergySource, MeleeAttack, PoiseChange, PoiseSource,
|
CharacterState, EnergyChange, EnergySource, MeleeAttack, PoiseChange, PoiseSource,
|
||||||
StateUpdate,
|
StateUpdate,
|
||||||
@ -196,12 +198,16 @@ impl CharacterBehavior for Data {
|
|||||||
+ self.combo * self.static_data.energy_increase,
|
+ self.combo * self.static_data.energy_increase,
|
||||||
);
|
);
|
||||||
let energy = AttackEffect::EnergyReward(energy);
|
let energy = AttackEffect::EnergyReward(energy);
|
||||||
|
let energy = EffectComponent::new(None, energy)
|
||||||
|
.with_requirement(CombatRequirement::AnyDamage);
|
||||||
let buff = AttackEffect::Buff(CombatBuff::default_melee());
|
let buff = AttackEffect::Buff(CombatBuff::default_melee());
|
||||||
let damage = DamageComponent::new(damage, Some(GroupTarget::OutOfGroup))
|
let damage = DamageComponent::new(damage, Some(GroupTarget::OutOfGroup))
|
||||||
.with_effect(knockback)
|
.with_effect(knockback)
|
||||||
.with_effect(energy)
|
|
||||||
.with_effect(buff);
|
.with_effect(buff);
|
||||||
let attack = Attack::default().with_damage(damage).with_crit(0.5, 1.3);
|
let attack = Attack::default()
|
||||||
|
.with_damage(damage)
|
||||||
|
.with_crit(0.5, 1.3)
|
||||||
|
.with_effect(energy);
|
||||||
|
|
||||||
data.updater.insert(data.entity, MeleeAttack {
|
data.updater.insert(data.entity, MeleeAttack {
|
||||||
attack,
|
attack,
|
||||||
|
Loading…
Reference in New Issue
Block a user