From faff715c4fe561ba8ff8f7de1bd23bc2056c74d3 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 24 Apr 2023 19:55:14 -0400 Subject: [PATCH] Simultaneous melee hits now show separately in SCT --- common/src/combat.rs | 8 +++++--- common/systems/src/beam.rs | 1 + common/systems/src/melee.rs | 3 ++- common/systems/src/projectile.rs | 1 + common/systems/src/shockwave.rs | 1 + server/src/events/entity_manipulation.rs | 1 + 6 files changed, 11 insertions(+), 4 deletions(-) diff --git a/common/src/combat.rs b/common/src/combat.rs index 7685423741..7026a14b4c 100644 --- a/common/src/combat.rs +++ b/common/src/combat.rs @@ -199,6 +199,7 @@ impl Attack { mut emit: impl FnMut(ServerEvent), mut emit_outcome: impl FnMut(Outcome), rng: &mut rand::rngs::ThreadRng, + damage_instance_offset: u64, ) -> bool { // TODO: Maybe move this higher and pass it as argument into this function? let msm = &MaterialStatManifest::load().read(); @@ -238,6 +239,7 @@ impl Attack { .filter(|d| d.target.map_or(true, |t| t == target_group)) .filter(|d| !avoid_damage(d)) { + let damage_instance = damage.instance + damage_instance_offset; is_applied = true; let damage_reduction = Attack::compute_damage_reduction( attacker.as_ref(), @@ -256,7 +258,7 @@ impl Attack { self.crit_multiplier, strength_modifier * damage_modifier, time, - damage.instance, + damage_instance, ); let applied_damage = -change.amount; accumulated_damage += applied_damage; @@ -282,7 +284,7 @@ impl Attack { cause: Some(damage.damage.source), time, crit: is_crit, - instance: damage.instance, + instance: damage_instance, }; emit(ServerEvent::HealthChange { entity: target.entity, @@ -331,7 +333,7 @@ impl Attack { amount: health_change, by: attacker.map(|x| x.into()), cause: Some(damage.damage.source), - instance: damage.instance, + instance: damage_instance, crit: is_crit, time, }; diff --git a/common/systems/src/beam.rs b/common/systems/src/beam.rs index f14d43ccd8..86ef024169 100644 --- a/common/systems/src/beam.rs +++ b/common/systems/src/beam.rs @@ -264,6 +264,7 @@ impl<'a> System<'a> for Sys { |e| server_events.push(e), |o| outcomes.push(o), &mut rng, + 0, ); add_hit_entities.push((beam_owner, *uid_b)); diff --git a/common/systems/src/melee.rs b/common/systems/src/melee.rs index d0a561573c..1be275ddbb 100644 --- a/common/systems/src/melee.rs +++ b/common/systems/src/melee.rs @@ -232,7 +232,7 @@ impl<'a> System<'a> for Sys { }; let mut is_applied = false; - for _ in 0..melee_attack.simultaneous_hits { + for offset in 0..melee_attack.simultaneous_hits { is_applied = melee_attack.attack.apply_attack( attacker_info, &target_info, @@ -244,6 +244,7 @@ impl<'a> System<'a> for Sys { |e| server_emitter.emit(e), |o| outcomes_emitter.emit(o), &mut rng, + offset as u64, ) || is_applied; } diff --git a/common/systems/src/projectile.rs b/common/systems/src/projectile.rs index cb1e3ec0c3..a713ebe1ae 100644 --- a/common/systems/src/projectile.rs +++ b/common/systems/src/projectile.rs @@ -361,6 +361,7 @@ fn dispatch_hit( |e| server_emitter.emit(e), |o| outcomes_emitter.emit(o), rng, + 0, ); }, projectile::Effect::Explode(e) => { diff --git a/common/systems/src/shockwave.rs b/common/systems/src/shockwave.rs index ea16a6e892..696ea49372 100644 --- a/common/systems/src/shockwave.rs +++ b/common/systems/src/shockwave.rs @@ -254,6 +254,7 @@ impl<'a> System<'a> for Sys { |e| server_emitter.emit(e), |o| outcomes_emitter.emit(o), &mut rng, + 0, ); shockwave_hit_list.hit_entities.push(*uid_b); diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index 90ce607d0d..b2dd0e57e5 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -1017,6 +1017,7 @@ pub fn handle_explosion(server: &Server, pos: Vec3, explosion: Explosion, o |e| emitter.emit(e), |o| outcomes_emitter.emit(o), &mut rng, + 0, ); } }