From 2b447852fdc31b94b7dbc504be842d62e67a14d2 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 27 Oct 2021 15:42:11 -0400 Subject: [PATCH 1/6] Added min fall off to explosions. --- .../common/abilities/custom/asp/firebomb.ron | 1 + .../custom/birdlargebreathe/firebomb.ron | 1 + .../custom/birdlargefire/firebomb.ron | 1 + .../abilities/custom/claygolem/rocket.ron | 1 + .../custom/harvester/explodingpumpkin.ron | 1 + .../abilities/custom/maneater/poisonball.ron | 1 + .../custom/mindflayer/necroticsphere.ron | 1 + .../custom/quadlowranged/firebomb.ron | 1 + .../custom/wendigomagic/frostbomb.ron | 1 + .../common/abilities/custom/yeti/snowball.ron | 1 + assets/common/abilities/staff/firebomb.ron | 1 + .../common/abilities/staffsimple/firebomb.ron | 1 + common/src/comp/projectile.rs | 34 +++++++++++++++++-- common/src/explosion.rs | 1 + server/src/cmd.rs | 1 + server/src/events/entity_manipulation.rs | 22 ++++++++++-- server/src/sys/object.rs | 2 ++ 17 files changed, 66 insertions(+), 6 deletions(-) diff --git a/assets/common/abilities/custom/asp/firebomb.ron b/assets/common/abilities/custom/asp/firebomb.ron index 738fb4c3f3..02b54ed7f3 100644 --- a/assets/common/abilities/custom/asp/firebomb.ron +++ b/assets/common/abilities/custom/asp/firebomb.ron @@ -6,6 +6,7 @@ BasicRanged( damage: 13.0, radius: 5.0, energy_regen: 0, + min_falloff: 0.5, ), projectile_body: Object(BoltFire), /*projectile_light: Some(LightEmitter { diff --git a/assets/common/abilities/custom/birdlargebreathe/firebomb.ron b/assets/common/abilities/custom/birdlargebreathe/firebomb.ron index f3d118976c..a3708e2740 100644 --- a/assets/common/abilities/custom/birdlargebreathe/firebomb.ron +++ b/assets/common/abilities/custom/birdlargebreathe/firebomb.ron @@ -6,6 +6,7 @@ BasicRanged( damage: 10.0, radius: 5.0, energy_regen: 5.0, + min_falloff: 0.5, ), projectile_body: Object(BoltFire), /*projectile_light: Some(LightEmitter { diff --git a/assets/common/abilities/custom/birdlargefire/firebomb.ron b/assets/common/abilities/custom/birdlargefire/firebomb.ron index f3d118976c..a3708e2740 100644 --- a/assets/common/abilities/custom/birdlargefire/firebomb.ron +++ b/assets/common/abilities/custom/birdlargefire/firebomb.ron @@ -6,6 +6,7 @@ BasicRanged( damage: 10.0, radius: 5.0, energy_regen: 5.0, + min_falloff: 0.5, ), projectile_body: Object(BoltFire), /*projectile_light: Some(LightEmitter { diff --git a/assets/common/abilities/custom/claygolem/rocket.ron b/assets/common/abilities/custom/claygolem/rocket.ron index a5b2a230c6..5b5a87cc02 100644 --- a/assets/common/abilities/custom/claygolem/rocket.ron +++ b/assets/common/abilities/custom/claygolem/rocket.ron @@ -6,6 +6,7 @@ BasicRanged( damage: 50.0, knockback: 18.0, radius: 5.0, + min_falloff: 0.75, ), projectile_body: Object(ClayRocket), projectile_light: None, diff --git a/assets/common/abilities/custom/harvester/explodingpumpkin.ron b/assets/common/abilities/custom/harvester/explodingpumpkin.ron index 5d76172c15..f302ab8c43 100644 --- a/assets/common/abilities/custom/harvester/explodingpumpkin.ron +++ b/assets/common/abilities/custom/harvester/explodingpumpkin.ron @@ -6,6 +6,7 @@ BasicRanged( damage: 20.0, knockback: 25.0, radius: 5.0, + min_falloff: 0.6, ), projectile_body: Object(Pumpkin), projectile_light: None, diff --git a/assets/common/abilities/custom/maneater/poisonball.ron b/assets/common/abilities/custom/maneater/poisonball.ron index 8b171eba68..8b13e59ecf 100644 --- a/assets/common/abilities/custom/maneater/poisonball.ron +++ b/assets/common/abilities/custom/maneater/poisonball.ron @@ -6,6 +6,7 @@ BasicRanged( damage: 26.0, radius: 5.0, energy_regen: 0, + min_falloff: 0.5, ), projectile_body: Object(FireworkPurple), /*projectile_light: Some(LightEmitter { diff --git a/assets/common/abilities/custom/mindflayer/necroticsphere.ron b/assets/common/abilities/custom/mindflayer/necroticsphere.ron index 52004b1bbf..e353fd46fe 100644 --- a/assets/common/abilities/custom/mindflayer/necroticsphere.ron +++ b/assets/common/abilities/custom/mindflayer/necroticsphere.ron @@ -5,6 +5,7 @@ BasicRanged( projectile: NecroticSphere( damage: 45.0, radius: 5.0, + min_falloff: 0.9, ), projectile_body: Object(FireworkPurple), projectile_speed: 100.0, diff --git a/assets/common/abilities/custom/quadlowranged/firebomb.ron b/assets/common/abilities/custom/quadlowranged/firebomb.ron index 27f0381ad8..7b4fe7b0f0 100644 --- a/assets/common/abilities/custom/quadlowranged/firebomb.ron +++ b/assets/common/abilities/custom/quadlowranged/firebomb.ron @@ -6,6 +6,7 @@ BasicRanged( damage: 13.0, radius: 5.0, energy_regen: 0, + min_falloff: 0.5, ), projectile_body: Object(FireworkPurple), /*projectile_light: Some(LightEmitter { diff --git a/assets/common/abilities/custom/wendigomagic/frostbomb.ron b/assets/common/abilities/custom/wendigomagic/frostbomb.ron index 732f397d76..55e0e0f542 100644 --- a/assets/common/abilities/custom/wendigomagic/frostbomb.ron +++ b/assets/common/abilities/custom/wendigomagic/frostbomb.ron @@ -5,6 +5,7 @@ BasicRanged( projectile: Frostball( damage: 12.0, radius: 5.0, + min_falloff: 0.5, ), projectile_body: Object(BoltFire), // TODO: Get ice projectile model /*projectile_light: Some(LightEmitter { diff --git a/assets/common/abilities/custom/yeti/snowball.ron b/assets/common/abilities/custom/yeti/snowball.ron index 3a53ac3d5b..e437a73f7a 100644 --- a/assets/common/abilities/custom/yeti/snowball.ron +++ b/assets/common/abilities/custom/yeti/snowball.ron @@ -5,6 +5,7 @@ BasicRanged( projectile: Snowball( damage: 20.0, radius: 5.0, + min_falloff: 0.7, ), projectile_body: Object(Snowball), projectile_speed: 60.0, diff --git a/assets/common/abilities/staff/firebomb.ron b/assets/common/abilities/staff/firebomb.ron index 21638365c7..2d9345ff77 100644 --- a/assets/common/abilities/staff/firebomb.ron +++ b/assets/common/abilities/staff/firebomb.ron @@ -6,6 +6,7 @@ BasicRanged( damage: 9.0, radius: 4.0, energy_regen: 6.0, + min_falloff: 0.5, ), projectile_body: Object(BoltFire), projectile_speed: 60.0, diff --git a/assets/common/abilities/staffsimple/firebomb.ron b/assets/common/abilities/staffsimple/firebomb.ron index 1c8278e077..5a0a996df2 100644 --- a/assets/common/abilities/staffsimple/firebomb.ron +++ b/assets/common/abilities/staffsimple/firebomb.ron @@ -6,6 +6,7 @@ BasicRanged( damage: 6.0, radius: 5.0, energy_regen: 5.0, + min_falloff: 0.5, ), projectile_body: Object(BoltFire), /*projectile_light: Some(LightEmitter { diff --git a/common/src/comp/projectile.rs b/common/src/comp/projectile.rs index 22c1a398c3..6dd5587711 100644 --- a/common/src/comp/projectile.rs +++ b/common/src/comp/projectile.rs @@ -54,29 +54,35 @@ pub enum ProjectileConstructor { damage: f32, radius: f32, energy_regen: f32, + min_falloff: f32, }, Frostball { damage: f32, radius: f32, + min_falloff: f32, }, NecroticSphere { damage: f32, radius: f32, + min_falloff: f32, }, Possess, ClayRocket { damage: f32, radius: f32, knockback: f32, + min_falloff: f32, }, Snowball { damage: f32, radius: f32, + min_falloff: f32, }, ExplodingPumpkin { damage: f32, radius: f32, knockback: f32, + min_falloff: f32, }, } @@ -141,6 +147,7 @@ impl ProjectileConstructor { damage, radius, energy_regen, + min_falloff, } => { let energy = AttackEffect::new(None, CombatEffect::EnergyReward(energy_regen)) .with_requirement(CombatRequirement::AnyDamage); @@ -164,6 +171,7 @@ impl ProjectileConstructor { ], radius, reagent: Some(Reagent::Red), + min_falloff, }; Projectile { hit_solid: vec![Effect::Explode(explosion.clone()), Effect::Vanish], @@ -175,7 +183,11 @@ impl ProjectileConstructor { is_point: true, } }, - Frostball { damage, radius } => { + Frostball { + damage, + radius, + min_falloff, + } => { let damage = AttackDamage::new( Damage { source: DamageSource::Explosion, @@ -192,6 +204,7 @@ impl ProjectileConstructor { effects: vec![RadiusEffect::Attack(attack)], radius, reagent: Some(Reagent::White), + min_falloff, }; Projectile { hit_solid: vec![Effect::Explode(explosion.clone()), Effect::Vanish], @@ -203,7 +216,11 @@ impl ProjectileConstructor { is_point: true, } }, - NecroticSphere { damage, radius } => { + NecroticSphere { + damage, + radius, + min_falloff, + } => { let damage = AttackDamage::new( Damage { source: DamageSource::Explosion, @@ -220,6 +237,7 @@ impl ProjectileConstructor { effects: vec![RadiusEffect::Attack(attack)], radius, reagent: Some(Reagent::Purple), + min_falloff, }; Projectile { hit_solid: vec![Effect::Explode(explosion.clone()), Effect::Vanish], @@ -244,6 +262,7 @@ impl ProjectileConstructor { damage, radius, knockback, + min_falloff, } => { let knockback = AttackEffect::new( Some(GroupTarget::OutOfGroup), @@ -272,6 +291,7 @@ impl ProjectileConstructor { ], radius, reagent: Some(Reagent::Red), + min_falloff, }; Projectile { hit_solid: vec![Effect::Explode(explosion.clone()), Effect::Vanish], @@ -283,7 +303,11 @@ impl ProjectileConstructor { is_point: true, } }, - Snowball { damage, radius } => { + Snowball { + damage, + radius, + min_falloff, + } => { let damage = AttackDamage::new( Damage { source: DamageSource::Explosion, @@ -299,6 +323,7 @@ impl ProjectileConstructor { effects: vec![RadiusEffect::Attack(attack)], radius, reagent: Some(Reagent::White), + min_falloff, }; Projectile { hit_solid: vec![], @@ -314,6 +339,7 @@ impl ProjectileConstructor { damage, radius, knockback, + min_falloff, } => { let knockback = AttackEffect::new( Some(GroupTarget::OutOfGroup), @@ -353,6 +379,7 @@ impl ProjectileConstructor { ], radius, reagent: Some(Reagent::Red), + min_falloff, }; Projectile { hit_solid: vec![Effect::Explode(explosion.clone()), Effect::Vanish], @@ -417,6 +444,7 @@ impl ProjectileConstructor { Snowball { ref mut damage, ref mut radius, + .. } => { *damage *= power; *radius *= range; diff --git a/common/src/explosion.rs b/common/src/explosion.rs index ac5790b976..ff02365cf5 100644 --- a/common/src/explosion.rs +++ b/common/src/explosion.rs @@ -6,6 +6,7 @@ pub struct Explosion { pub effects: Vec, pub radius: f32, pub reagent: Option, + pub min_falloff: f32, } #[derive(Clone, Debug, Serialize, Deserialize)] diff --git a/server/src/cmd.rs b/server/src/cmd.rs index 375e4ccc08..ba1d9c3c37 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -2033,6 +2033,7 @@ fn handle_explosion( ], radius: 3.0 * power, reagent: None, + min_falloff: 0.0, }, owner, }); diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index 24de925db5..592039e7c0 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -546,6 +546,7 @@ pub fn handle_explosion(server: &Server, pos: Vec3, explosion: Explosion, o fn cylinder_sphere_strength( sphere_pos: Vec3, radius: f32, + min_falloff: f32, cyl_pos: Vec3, cyl_body: Body, ) -> f32 { @@ -559,7 +560,10 @@ pub fn handle_explosion(server: &Server, pos: Vec3, explosion: Explosion, o // Compare both checks, take whichever gives weaker effect, sets minimum of 0 so // that explosions reach a max strength on edge of entity - ((horiz_dist.max(vert_distance).max(0.0) / radius).min(1.0) - 1.0).abs() + let fall_off = ((horiz_dist.max(vert_distance).max(0.0) / radius).min(1.0) - 1.0).abs(); + // Clamp min_falloff so that it doesn't produce absurd values or NaNs + let min_falloff = min_falloff.clamp(0.0, 0.99); + min_falloff + fall_off * (1.0 - min_falloff) } // TODO: Faster RNG? @@ -714,7 +718,13 @@ pub fn handle_explosion(server: &Server, pos: Vec3, explosion: Explosion, o { // Check if it is a hit let strength = if let Some(body) = body_b_maybe { - cylinder_sphere_strength(pos, explosion.radius, pos_b.0, *body) + cylinder_sphere_strength( + pos, + explosion.radius, + explosion.min_falloff, + pos_b.0, + *body, + ) } else { let distance_squared = pos.distance_squared(pos_b.0); 1.0 - distance_squared / explosion.radius.powi(2) @@ -801,7 +811,13 @@ pub fn handle_explosion(server: &Server, pos: Vec3, explosion: Explosion, o .join() { let strength = if let Some(body) = body_b_maybe { - cylinder_sphere_strength(pos, explosion.radius, pos_b.0, *body) + cylinder_sphere_strength( + pos, + explosion.radius, + explosion.min_falloff, + pos_b.0, + *body, + ) } else { let distance_squared = pos.distance_squared(pos_b.0); 1.0 - distance_squared / explosion.radius.powi(2) diff --git a/server/src/sys/object.rs b/server/src/sys/object.rs index 9736d157cc..44533ce8e1 100644 --- a/server/src/sys/object.rs +++ b/server/src/sys/object.rs @@ -61,6 +61,7 @@ impl<'a> System<'a> for Sys { ], radius: 12.0, reagent: None, + min_falloff: 0.75, }, owner: *owner, }); @@ -153,6 +154,7 @@ impl<'a> System<'a> for Sys { ], radius: 12.0, reagent: Some(*reagent), + min_falloff: 0.0, }, owner: *owner, }); From 696da74c9493052b5b72f48c78b823cf494fd12e Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 27 Oct 2021 15:55:25 -0400 Subject: [PATCH 2/6] Fixed falloff calculations --- server/src/events/entity_manipulation.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index 592039e7c0..8c07702ae0 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -558,12 +558,20 @@ pub fn handle_explosion(server: &Server, pos: Vec3, explosion: Explosion, o let vert_distance = (sphere_pos.z - (cyl_pos.z + half_body_height)).abs() - half_body_height; - // Compare both checks, take whichever gives weaker effect, sets minimum of 0 so - // that explosions reach a max strength on edge of entity - let fall_off = ((horiz_dist.max(vert_distance).max(0.0) / radius).min(1.0) - 1.0).abs(); - // Clamp min_falloff so that it doesn't produce absurd values or NaNs - let min_falloff = min_falloff.clamp(0.0, 0.99); - min_falloff + fall_off * (1.0 - min_falloff) + // Use whichever gives maximum distance as that closer to real value. Sets + // minimum to 0 as negative values would indicate inside entity. + let distance = horiz_dist.max(vert_distance).max(0.0); + + if distance > radius { + // If further than exploion radius, no strength + 0.0 + } else { + // Falloff inversely proportional to radius + let fall_off = ((horiz_dist.max(vert_distance).max(0.0) / radius).min(1.0) - 1.0).abs(); + // Clamp min_falloff so that it doesn't produce absurd values or NaNs + let min_falloff = min_falloff.clamp(0.0, 0.99); + min_falloff + fall_off * (1.0 - min_falloff) + } } // TODO: Faster RNG? From f339793911447f5e7d39eab80fc9fef9b5b035b5 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 27 Oct 2021 17:19:29 -0400 Subject: [PATCH 3/6] Buffed staff firebomb a little. --- assets/common/abilities/staff/firebomb.ron | 2 +- common/src/comp/projectile.rs | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/assets/common/abilities/staff/firebomb.ron b/assets/common/abilities/staff/firebomb.ron index 2d9345ff77..b06b67dca5 100644 --- a/assets/common/abilities/staff/firebomb.ron +++ b/assets/common/abilities/staff/firebomb.ron @@ -5,7 +5,7 @@ BasicRanged( projectile: Fireball( damage: 9.0, radius: 4.0, - energy_regen: 6.0, + energy_regen: 10.0, min_falloff: 0.5, ), projectile_body: Object(BoltFire), diff --git a/common/src/comp/projectile.rs b/common/src/comp/projectile.rs index 6dd5587711..c88e8db160 100644 --- a/common/src/comp/projectile.rs +++ b/common/src/comp/projectile.rs @@ -151,6 +151,12 @@ impl ProjectileConstructor { } => { let energy = AttackEffect::new(None, CombatEffect::EnergyReward(energy_regen)) .with_requirement(CombatRequirement::AnyDamage); + let buff = CombatEffect::Buff(CombatBuff { + kind: BuffKind::Bleeding, + dur_secs: 5.0, + strength: CombatBuffStrength::DamageFraction(0.1 * buff_strength), + chance: 0.1, + }); let damage = AttackDamage::new( Damage { source: DamageSource::Explosion, @@ -158,7 +164,8 @@ impl ProjectileConstructor { value: damage, }, Some(GroupTarget::OutOfGroup), - ); + ) + .with_effect(buff); let attack = Attack::default() .with_damage(damage) .with_crit(crit_chance, crit_mult) From 57851b7df3a796d46efe32690a85810b278f7a37 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 27 Oct 2021 23:05:54 -0400 Subject: [PATCH 4/6] Fixed buff applied. --- common/src/comp/projectile.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/comp/projectile.rs b/common/src/comp/projectile.rs index c88e8db160..290b11dafe 100644 --- a/common/src/comp/projectile.rs +++ b/common/src/comp/projectile.rs @@ -152,7 +152,7 @@ impl ProjectileConstructor { let energy = AttackEffect::new(None, CombatEffect::EnergyReward(energy_regen)) .with_requirement(CombatRequirement::AnyDamage); let buff = CombatEffect::Buff(CombatBuff { - kind: BuffKind::Bleeding, + kind: BuffKind::Burning, dur_secs: 5.0, strength: CombatBuffStrength::DamageFraction(0.1 * buff_strength), chance: 0.1, From ca292a53eac24372a7400f9cc387209ed5d1c478 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 28 Oct 2021 18:37:51 -0400 Subject: [PATCH 5/6] All aspects of an attack now scale with the modifier. --- common/src/combat.rs | 53 ++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/common/src/combat.rs b/common/src/combat.rs index 619cb30084..a554acd9e1 100644 --- a/common/src/combat.rs +++ b/common/src/combat.rs @@ -227,7 +227,7 @@ impl Attack { self.crit_multiplier, strength_modifier, ); - let applied_damage = -change.amount as f32; + let applied_damage = -change.amount; accumulated_damage += applied_damage; emit_outcome(Outcome::Damage { pos: target.pos }); if change.amount.abs() > Health::HEALTH_EPSILON { @@ -238,7 +238,7 @@ impl Attack { for effect in damage.effects.iter() { match effect { CombatEffect::Knockback(kb) => { - let impulse = kb.calculate_impulse(dir); + let impulse = kb.calculate_impulse(dir) * strength_modifier; if !impulse.is_approx_zero() { emit(ServerEvent::Knockback { entity: target.entity, @@ -250,7 +250,9 @@ impl Attack { if let Some(attacker) = attacker { emit(ServerEvent::EnergyChange { entity: attacker.entity, - change: *ec * compute_energy_reward_mod(attacker.inventory), + change: *ec + * compute_energy_reward_mod(attacker.inventory) + * strength_modifier, }); } }, @@ -258,13 +260,16 @@ impl Attack { if thread_rng().gen::() < b.chance { emit(ServerEvent::Buff { entity: target.entity, - buff_change: BuffChange::Add( - b.to_buff(attacker.map(|a| a.uid), applied_damage), - ), + buff_change: BuffChange::Add(b.to_buff( + attacker.map(|a| a.uid), + applied_damage, + strength_modifier, + )), }); } }, CombatEffect::Lifesteal(l) => { + // Not modified by strength_modifer as damage already is if let Some(attacker_entity) = attacker.map(|a| a.entity) { let change = HealthChange { amount: applied_damage * l, @@ -280,7 +285,8 @@ impl Attack { } }, CombatEffect::Poise(p) => { - let change = -Poise::apply_poise_reduction(*p, target.inventory); + let change = -Poise::apply_poise_reduction(*p, target.inventory) + * strength_modifier; if change.abs() > Poise::POISE_EPSILON { emit(ServerEvent::PoiseChange { entity: target.entity, @@ -291,7 +297,7 @@ impl Attack { }, CombatEffect::Heal(h) => { let change = HealthChange { - amount: *h, + amount: *h * strength_modifier, by: attacker.map(|a| a.uid), cause: None, }; @@ -303,6 +309,7 @@ impl Attack { } }, CombatEffect::Combo(c) => { + // Not affected by strength modifier as integer if let Some(attacker_entity) = attacker.map(|a| a.entity) { emit(ServerEvent::ComboChange { entity: attacker_entity, @@ -366,7 +373,7 @@ impl Attack { is_applied = true; match effect.effect { CombatEffect::Knockback(kb) => { - let impulse = kb.calculate_impulse(dir); + let impulse = kb.calculate_impulse(dir) * strength_modifier; if !impulse.is_approx_zero() { emit(ServerEvent::Knockback { entity: target.entity, @@ -378,7 +385,9 @@ impl Attack { if let Some(attacker) = attacker { emit(ServerEvent::EnergyChange { entity: attacker.entity, - change: ec * compute_energy_reward_mod(attacker.inventory), + change: ec + * compute_energy_reward_mod(attacker.inventory) + * strength_modifier, }); } }, @@ -386,13 +395,16 @@ impl Attack { if thread_rng().gen::() < b.chance { emit(ServerEvent::Buff { entity: target.entity, - buff_change: BuffChange::Add( - b.to_buff(attacker.map(|a| a.uid), accumulated_damage), - ), + buff_change: BuffChange::Add(b.to_buff( + attacker.map(|a| a.uid), + accumulated_damage, + strength_modifier, + )), }); } }, CombatEffect::Lifesteal(l) => { + // Not modified by strength_modifer as damage already is if let Some(attacker_entity) = attacker.map(|a| a.entity) { let change = HealthChange { amount: accumulated_damage * l, @@ -408,7 +420,8 @@ impl Attack { } }, CombatEffect::Poise(p) => { - let change = -Poise::apply_poise_reduction(p, target.inventory); + let change = + -Poise::apply_poise_reduction(p, target.inventory) * strength_modifier; if change.abs() > Poise::POISE_EPSILON { emit(ServerEvent::PoiseChange { entity: target.entity, @@ -419,7 +432,7 @@ impl Attack { }, CombatEffect::Heal(h) => { let change = HealthChange { - amount: h, + amount: h * strength_modifier, by: attacker.map(|a| a.uid), cause: None, }; @@ -431,6 +444,7 @@ impl Attack { } }, CombatEffect::Combo(c) => { + // Not affected by strength modifier as integer if let Some(attacker_entity) = attacker.map(|a| a.entity) { emit(ServerEvent::ComboChange { entity: attacker_entity, @@ -768,10 +782,11 @@ pub enum CombatBuffStrength { #[cfg(not(target_arch = "wasm32"))] impl CombatBuffStrength { - fn to_strength(self, damage: f32) -> f32 { + fn to_strength(self, damage: f32, strength_modifier: f32) -> f32 { match self { + // Not affected by strength modifier as damage already is CombatBuffStrength::DamageFraction(f) => damage * f, - CombatBuffStrength::Value(v) => v, + CombatBuffStrength::Value(v) => v * strength_modifier, } } } @@ -788,7 +803,7 @@ impl MulAssign for CombatBuffStrength { #[cfg(not(target_arch = "wasm32"))] impl CombatBuff { - fn to_buff(self, uid: Option, damage: f32) -> Buff { + fn to_buff(self, uid: Option, damage: f32, strength_modifier: f32) -> Buff { // TODO: Generate BufCategoryId vec (probably requires damage overhaul?) let source = if let Some(uid) = uid { BuffSource::Character { by: uid } @@ -798,7 +813,7 @@ impl CombatBuff { Buff::new( self.kind, BuffData::new( - self.strength.to_strength(damage), + self.strength.to_strength(damage, strength_modifier), Some(Duration::from_secs_f32(self.dur_secs)), ), Vec::new(), From aad2384622fd125da8c7a10184fea2df5be42293 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 29 Oct 2021 17:12:57 -0400 Subject: [PATCH 6/6] Addressed review, changelog. --- CHANGELOG.md | 1 + server/src/events/entity_manipulation.rs | 5 ++--- server/src/sys/agent.rs | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0492fd47d5..85bbf6e562 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Nerfed some skill values - Tweaked critical chance of legendary weapons - Agents using fireball projectiles aim at the feet instead of the eyes +- Explosions can now have a nonzero minimum falloff ### Removed diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index 8c07702ae0..8b98efce3e 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -567,9 +567,8 @@ pub fn handle_explosion(server: &Server, pos: Vec3, explosion: Explosion, o 0.0 } else { // Falloff inversely proportional to radius - let fall_off = ((horiz_dist.max(vert_distance).max(0.0) / radius).min(1.0) - 1.0).abs(); - // Clamp min_falloff so that it doesn't produce absurd values or NaNs - let min_falloff = min_falloff.clamp(0.0, 0.99); + let fall_off = ((distance / radius).min(1.0) - 1.0).abs(); + let min_falloff = min_falloff.clamp(0.0, 1.0); min_falloff + fall_off * (1.0 - min_falloff) } } diff --git a/server/src/sys/agent.rs b/server/src/sys/agent.rs index 1e1940a84c..a7768d7187 100644 --- a/server/src/sys/agent.rs +++ b/server/src/sys/agent.rs @@ -1862,6 +1862,7 @@ impl<'a> AgentData<'a> { damage: _, radius: _, energy_regen: _, + min_falloff: _, } => 0.0, _ => tgt_eye_offset, };