diff --git a/common/src/combat.rs b/common/src/combat.rs index 33ef2227ff..a0e4ae075e 100644 --- a/common/src/combat.rs +++ b/common/src/combat.rs @@ -66,6 +66,8 @@ impl Attack { self } + pub fn effects(&self) -> impl Iterator { self.effects.iter() } + #[allow(clippy::too_many_arguments)] pub fn apply_attack( &self, @@ -303,6 +305,8 @@ impl EffectComponent { self.requirement = Some(requirement); self } + + pub fn effect(&self) -> &AttackEffect { &self.effect } } #[derive(Clone, Debug, Serialize, Deserialize)] diff --git a/common/src/comp/beam.rs b/common/src/comp/beam.rs index f5d06266e2..60b722aed6 100644 --- a/common/src/comp/beam.rs +++ b/common/src/comp/beam.rs @@ -9,9 +9,6 @@ pub struct Properties { pub attack: Attack, pub angle: f32, pub speed: f32, - //pub lifesteal_eff: f32, - //pub energy_regen: u32, - //pub energy_cost: u32, pub duration: Duration, pub owner: Option, } diff --git a/server/src/events/entity_creation.rs b/server/src/events/entity_creation.rs index 1464a420c8..052c5be8e5 100644 --- a/server/src/events/entity_creation.rs +++ b/server/src/events/entity_creation.rs @@ -1,6 +1,7 @@ use crate::{sys, Server, StateExt}; use common::{ character::CharacterId, + combat, comp::{ self, aura::{Aura, AuraKind, AuraTarget}, @@ -170,7 +171,10 @@ pub fn handle_beam(server: &mut Server, properties: beam::Properties, pos: Pos, let ecs = state.ecs(); ecs.write_resource::>().push(Outcome::Beam { pos: pos.0, - heal: false, //properties.lifesteal_eff > 0.0, // Fix before merging + heal: properties + .attack + .effects() + .any(|e| matches!(e.effect(), combat::AttackEffect::Heal(h) if *h > 0.0)), }); state.create_beam(properties, pos, ori).build(); } diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index a5f453c333..1185f8c8fa 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -577,24 +577,21 @@ pub fn handle_explosion( // Add an outcome // Uses radius as outcome power, makes negative if explosion has healing effect - let outcome_power = explosion.radius; - // - // * if explosion.effects.iter().any(|e| { matches!( e, RadiusEffect::Entity( _, - // Effect::Damage(Damage { source: DamageSource::Healing, .. }) ) ) - // }) { - // -1.0 - // } else { - // 1.0 - // }; + let outcome_power = explosion.radius + * if explosion.effects.iter().any(|e| matches!(e, RadiusEffect::Attack(a) if a.effects().any(|e| matches!(e.effect(), combat::AttackEffect::Heal(h) if *h > 0.0)))) { + -1.0 + } else { + 1.0 + }; ecs.write_resource::>() .push(Outcome::Explosion { pos, power: outcome_power, radius: explosion.radius, - is_attack: false, /*explosion - .effects - .iter() - .any(|e| matches!(e, RadiusEffect::Entity(_, Effect::Damage(_))))*/ + is_attack: explosion + .effects + .iter() + .any(|e| matches!(e, RadiusEffect::Attack(_))), reagent, }); let owner_entity = owner.and_then(|uid| {