diff --git a/common/src/combat.rs b/common/src/combat.rs index a0e4ae075e..b1e9be63d8 100644 --- a/common/src/combat.rs +++ b/common/src/combat.rs @@ -98,8 +98,8 @@ impl Attack { self.crit_multiplier, strength_modifier, ); - let damage_damage = -change.amount as f32; - accumulated_damage += damage_damage; + let applied_damage = -change.amount as f32; + accumulated_damage += applied_damage; if change.amount != 0 { server_events.push(ServerEvent::Damage { entity: target_entity, @@ -130,14 +130,14 @@ impl Attack { server_events.push(ServerEvent::Buff { entity: target_entity, buff_change: BuffChange::Add( - b.to_buff(attacker_uid, damage_damage), + b.to_buff(attacker_uid, applied_damage), ), }); } }, AttackEffect::Lifesteal(l) => { let change = HealthChange { - amount: (damage_damage * l) as i32, + amount: (applied_damage * l) as i32, cause: HealthSource::Heal { by: Some(attacker_uid), }, diff --git a/common/src/comp/projectile.rs b/common/src/comp/projectile.rs index 5cb2326593..b35b512f44 100644 --- a/common/src/comp/projectile.rs +++ b/common/src/comp/projectile.rs @@ -76,25 +76,27 @@ impl ProjectileConstructor { knockback, energy_regen, } => { - let damage = Damage { - source: DamageSource::Projectile, - value: damage, - }; let knockback = AttackEffect::Knockback(Knockback { strength: knockback, direction: KnockbackDir::Away, }); + let knockback = EffectComponent::new(Some(GroupTarget::OutOfGroup), knockback) + .with_requirement(CombatRequirement::AnyDamage); let energy = AttackEffect::EnergyReward(energy_regen); let energy = EffectComponent::new(None, energy) .with_requirement(CombatRequirement::AnyDamage); let buff = AttackEffect::Buff(CombatBuff::default_physical()); - let damage = DamageComponent::new(damage, Some(GroupTarget::OutOfGroup)) - .with_effect(knockback) - .with_effect(buff); + let damage = Damage { + source: DamageSource::Projectile, + value: damage, + }; + let damage = + DamageComponent::new(damage, Some(GroupTarget::OutOfGroup)).with_effect(buff); let attack = Attack::default() .with_damage(damage) .with_crit(0.5, 1.2) - .with_effect(energy); + .with_effect(energy) + .with_effect(knockback); Projectile { hit_solid: vec![Effect::Stick], @@ -109,13 +111,13 @@ impl ProjectileConstructor { radius, energy_regen, } => { + let energy = AttackEffect::EnergyReward(energy_regen); + let energy = EffectComponent::new(None, energy) + .with_requirement(CombatRequirement::AnyDamage); let damage = Damage { source: DamageSource::Explosion, value: damage, }; - let energy = AttackEffect::EnergyReward(energy_regen); - let energy = EffectComponent::new(None, energy) - .with_requirement(CombatRequirement::AnyDamage); let damage = DamageComponent::new(damage, Some(GroupTarget::OutOfGroup)); let attack = Attack::default().with_damage(damage).with_effect(energy); let explosion = Explosion { @@ -137,13 +139,13 @@ impl ProjectileConstructor { damage, energy_regen, } => { + let energy = AttackEffect::EnergyReward(energy_regen); + let energy = EffectComponent::new(None, energy) + .with_requirement(CombatRequirement::AnyDamage); let damage = Damage { source: DamageSource::Energy, value: damage, }; - let energy = AttackEffect::EnergyReward(energy_regen); - let energy = EffectComponent::new(None, energy) - .with_requirement(CombatRequirement::AnyDamage); let damage = DamageComponent::new(damage, Some(GroupTarget::OutOfGroup)); let attack = Attack::default().with_damage(damage).with_effect(energy); diff --git a/common/src/states/basic_melee.rs b/common/src/states/basic_melee.rs index 5b1bd9b9c9..778d624fbb 100644 --- a/common/src/states/basic_melee.rs +++ b/common/src/states/basic_melee.rs @@ -92,10 +92,6 @@ impl CharacterBehavior for Data { ..*self }); - let damage = Damage { - source: DamageSource::Melee, - value: self.static_data.base_damage as f32, - }; let poise = AttackEffect::Poise(self.static_data.base_poise_damage as f32); let poise = EffectComponent::new(Some(GroupTarget::OutOfGroup), poise) .with_requirement(CombatRequirement::AnyDamage); @@ -103,18 +99,24 @@ impl CharacterBehavior for Data { strength: self.static_data.knockback, direction: KnockbackDir::Away, }); + let knockback = EffectComponent::new(Some(GroupTarget::OutOfGroup), knockback) + .with_requirement(CombatRequirement::AnyDamage); let energy = AttackEffect::EnergyReward(50); let energy = EffectComponent::new(None, energy) .with_requirement(CombatRequirement::AnyDamage); let buff = AttackEffect::Buff(CombatBuff::default_physical()); + let damage = Damage { + source: DamageSource::Melee, + value: self.static_data.base_damage as f32, + }; let damage = DamageComponent::new(damage, Some(GroupTarget::OutOfGroup)) - .with_effect(knockback) .with_effect(buff); let attack = Attack::default() .with_damage(damage) .with_crit(0.5, 1.3) .with_effect(energy) - .with_effect(poise); + .with_effect(poise) + .with_effect(knockback); // Hit attempt data.updater.insert(data.entity, MeleeAttack { diff --git a/common/src/states/charged_melee.rs b/common/src/states/charged_melee.rs index 2558d133cb..d8144b96b0 100644 --- a/common/src/states/charged_melee.rs +++ b/common/src/states/charged_melee.rs @@ -155,11 +155,6 @@ impl CharacterBehavior for Data { exhausted: true, ..*self }); - let damage = Damage { - source: DamageSource::Melee, - value: self.static_data.initial_damage as f32 - + self.charge_amount * self.static_data.scaled_damage as f32, - }; let poise = self.static_data.initial_poise_damage as f32 + self.charge_amount * self.static_data.scaled_poise_damage as f32; let poise = AttackEffect::Poise(poise); @@ -171,14 +166,21 @@ impl CharacterBehavior for Data { strength: knockback, direction: KnockbackDir::Away, }); + let knockback = EffectComponent::new(Some(GroupTarget::OutOfGroup), knockback) + .with_requirement(CombatRequirement::AnyDamage); let buff = AttackEffect::Buff(CombatBuff::default_physical()); + let damage = Damage { + source: DamageSource::Melee, + value: self.static_data.initial_damage as f32 + + self.charge_amount * self.static_data.scaled_damage as f32, + }; let damage = DamageComponent::new(damage, Some(GroupTarget::OutOfGroup)) - .with_effect(knockback) .with_effect(buff); let attack = Attack::default() .with_damage(damage) .with_crit(0.5, 1.3) - .with_effect(poise); + .with_effect(poise) + .with_effect(knockback); // Hit attempt data.updater.insert(data.entity, MeleeAttack { diff --git a/common/src/states/charged_ranged.rs b/common/src/states/charged_ranged.rs index f53f7b2f14..5759024143 100644 --- a/common/src/states/charged_ranged.rs +++ b/common/src/states/charged_ranged.rs @@ -1,7 +1,7 @@ use crate::{ combat::{ - Attack, AttackEffect, CombatBuff, Damage, DamageComponent, DamageSource, GroupTarget, - Knockback, KnockbackDir, + Attack, AttackEffect, CombatBuff, CombatRequirement, Damage, DamageComponent, DamageSource, + EffectComponent, GroupTarget, Knockback, KnockbackDir, }, comp::{ projectile, Body, CharacterState, EnergyChange, EnergySource, Gravity, LightEmitter, @@ -103,22 +103,26 @@ impl CharacterBehavior for Data { let charge_frac = (self.timer.as_secs_f32() / self.static_data.charge_duration.as_secs_f32()) .min(1.0); - let damage = Damage { - source: DamageSource::Projectile, - value: self.static_data.initial_damage as f32 - + charge_frac * self.static_data.scaled_damage as f32, - }; let knockback = self.static_data.initial_knockback + charge_frac * self.static_data.scaled_knockback; let knockback = AttackEffect::Knockback(Knockback { strength: knockback, direction: KnockbackDir::Away, }); + let knockback = EffectComponent::new(Some(GroupTarget::OutOfGroup), knockback) + .with_requirement(CombatRequirement::AnyDamage); let buff = AttackEffect::Buff(CombatBuff::default_physical()); + let damage = Damage { + source: DamageSource::Projectile, + value: self.static_data.initial_damage as f32 + + charge_frac * self.static_data.scaled_damage as f32, + }; let damage = DamageComponent::new(damage, Some(GroupTarget::OutOfGroup)) - .with_effect(knockback) .with_effect(buff); - let attack = Attack::default().with_damage(damage).with_crit(0.5, 1.2); + let attack = Attack::default() + .with_damage(damage) + .with_crit(0.5, 1.2) + .with_effect(knockback); // Fire let projectile = Projectile { diff --git a/common/src/states/combo_melee.rs b/common/src/states/combo_melee.rs index 85763ff24b..3a24c54151 100644 --- a/common/src/states/combo_melee.rs +++ b/common/src/states/combo_melee.rs @@ -185,14 +185,12 @@ impl CharacterBehavior for Data { let poise = EffectComponent::new(Some(GroupTarget::OutOfGroup), poise) .with_requirement(CombatRequirement::AnyDamage); - let damage = Damage { - source: DamageSource::Melee, - value: damage as f32, - }; let knockback = AttackEffect::Knockback(Knockback { strength: self.static_data.stage_data[stage_index].knockback, direction: KnockbackDir::Away, }); + let knockback = EffectComponent::new(Some(GroupTarget::OutOfGroup), knockback) + .with_requirement(CombatRequirement::AnyDamage); let energy = self.static_data.max_energy_gain.min( self.static_data.initial_energy_gain + self.combo * self.static_data.energy_increase, @@ -201,14 +199,18 @@ impl CharacterBehavior for Data { let energy = EffectComponent::new(None, energy) .with_requirement(CombatRequirement::AnyDamage); let buff = AttackEffect::Buff(CombatBuff::default_physical()); + let damage = Damage { + source: DamageSource::Melee, + value: damage as f32, + }; let damage = DamageComponent::new(damage, Some(GroupTarget::OutOfGroup)) - .with_effect(knockback) .with_effect(buff); let attack = Attack::default() .with_damage(damage) .with_crit(0.5, 1.3) .with_effect(energy) - .with_effect(poise); + .with_effect(poise) + .with_effect(knockback); data.updater.insert(data.entity, MeleeAttack { attack, diff --git a/common/src/states/dash_melee.rs b/common/src/states/dash_melee.rs index 93e73ec006..74191a1c42 100644 --- a/common/src/states/dash_melee.rs +++ b/common/src/states/dash_melee.rs @@ -132,11 +132,6 @@ impl CharacterBehavior for Data { if !self.exhausted { // Hit attempt (also checks if player is moving) if update.vel.0.distance_squared(Vec3::zero()) > 1.0 { - let damage = Damage { - source: DamageSource::Melee, - value: self.static_data.base_damage as f32 - + charge_frac * self.static_data.scaled_damage as f32, - }; let poise = self.static_data.base_poise_damage as f32 + charge_frac * self.static_data.scaled_poise_damage as f32; let poise = AttackEffect::Poise(poise); @@ -148,15 +143,23 @@ impl CharacterBehavior for Data { strength: knockback, direction: KnockbackDir::Away, }); + let knockback = + EffectComponent::new(Some(GroupTarget::OutOfGroup), knockback) + .with_requirement(CombatRequirement::AnyDamage); let buff = AttackEffect::Buff(CombatBuff::default_physical()); + let damage = Damage { + source: DamageSource::Melee, + value: self.static_data.base_damage as f32 + + charge_frac * self.static_data.scaled_damage as f32, + }; let damage = DamageComponent::new(damage, Some(GroupTarget::OutOfGroup)) - .with_effect(knockback) .with_effect(buff); let attack = Attack::default() .with_damage(damage) .with_crit(0.5, 1.3) - .with_effect(poise); + .with_effect(poise) + .with_effect(knockback); data.updater.insert(data.entity, MeleeAttack { attack, diff --git a/common/src/states/leap_melee.rs b/common/src/states/leap_melee.rs index d6bb8a2e9b..799bc37337 100644 --- a/common/src/states/leap_melee.rs +++ b/common/src/states/leap_melee.rs @@ -150,10 +150,6 @@ impl CharacterBehavior for Data { }, StageSection::Recover => { if !self.exhausted { - let damage = Damage { - source: DamageSource::Melee, - value: self.static_data.base_damage as f32, - }; let poise = AttackEffect::Poise(self.static_data.base_poise_damage as f32); let poise = EffectComponent::new(Some(GroupTarget::OutOfGroup), poise) .with_requirement(CombatRequirement::AnyDamage); @@ -161,14 +157,20 @@ impl CharacterBehavior for Data { strength: self.static_data.knockback, direction: KnockbackDir::Away, }); + let knockback = EffectComponent::new(Some(GroupTarget::OutOfGroup), knockback) + .with_requirement(CombatRequirement::AnyDamage); let buff = AttackEffect::Buff(CombatBuff::default_physical()); + let damage = Damage { + source: DamageSource::Melee, + value: self.static_data.base_damage as f32, + }; let damage = DamageComponent::new(damage, Some(GroupTarget::OutOfGroup)) - .with_effect(knockback) .with_effect(buff); let attack = Attack::default() .with_damage(damage) .with_crit(0.5, 1.3) - .with_effect(poise); + .with_effect(poise) + .with_effect(knockback); // Hit attempt, when animation plays data.updater.insert(data.entity, MeleeAttack { diff --git a/common/src/states/shockwave.rs b/common/src/states/shockwave.rs index 38dcc213e1..2cb3ca6071 100644 --- a/common/src/states/shockwave.rs +++ b/common/src/states/shockwave.rs @@ -83,17 +83,21 @@ impl CharacterBehavior for Data { }); } else { // Attack - let damage = Damage { - source: DamageSource::Shockwave, - value: self.static_data.damage as f32, - }; let poise = AttackEffect::Poise(self.static_data.poise_damage as f32); let poise = EffectComponent::new(Some(GroupTarget::OutOfGroup), poise) .with_requirement(CombatRequirement::AnyDamage); let knockback = AttackEffect::Knockback(self.static_data.knockback); - let damage = DamageComponent::new(damage, Some(GroupTarget::OutOfGroup)) + let knockback = EffectComponent::new(Some(GroupTarget::OutOfGroup), knockback) + .with_requirement(CombatRequirement::AnyDamage); + let damage = Damage { + source: DamageSource::Shockwave, + value: self.static_data.damage as f32, + }; + let damage = DamageComponent::new(damage, Some(GroupTarget::OutOfGroup)); + let attack = Attack::default() + .with_damage(damage) + .with_effect(poise) .with_effect(knockback); - let attack = Attack::default().with_damage(damage).with_effect(poise); let properties = shockwave::Properties { angle: self.static_data.shockwave_angle, vertical_angle: self.static_data.shockwave_vertical_angle, diff --git a/common/src/states/spin_melee.rs b/common/src/states/spin_melee.rs index dfd2aa677b..ca0b1f6220 100644 --- a/common/src/states/spin_melee.rs +++ b/common/src/states/spin_melee.rs @@ -115,10 +115,6 @@ impl CharacterBehavior for Data { ..*self }); - let damage = Damage { - source: DamageSource::Melee, - value: self.static_data.base_damage as f32, - }; let poise = AttackEffect::Poise(self.static_data.base_poise_damage as f32); let poise = EffectComponent::new(Some(GroupTarget::OutOfGroup), poise) .with_requirement(CombatRequirement::AnyDamage); @@ -126,14 +122,20 @@ impl CharacterBehavior for Data { strength: self.static_data.knockback, direction: KnockbackDir::Away, }); + let knockback = EffectComponent::new(Some(GroupTarget::OutOfGroup), knockback) + .with_requirement(CombatRequirement::AnyDamage); let buff = AttackEffect::Buff(CombatBuff::default_physical()); + let damage = Damage { + source: DamageSource::Melee, + value: self.static_data.base_damage as f32, + }; let damage = DamageComponent::new(damage, Some(GroupTarget::OutOfGroup)) - .with_effect(knockback) .with_effect(buff); let attack = Attack::default() .with_damage(damage) .with_crit(0.5, 1.3) - .with_effect(poise); + .with_effect(poise) + .with_effect(knockback); // Hit attempt data.updater.insert(data.entity, MeleeAttack {