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/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..b06b67dca5 100644 --- a/assets/common/abilities/staff/firebomb.ron +++ b/assets/common/abilities/staff/firebomb.ron @@ -5,7 +5,8 @@ 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), 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/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(), diff --git a/common/src/comp/projectile.rs b/common/src/comp/projectile.rs index 22c1a398c3..290b11dafe 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,9 +147,16 @@ impl ProjectileConstructor { damage, radius, energy_regen, + min_falloff, } => { let energy = AttackEffect::new(None, CombatEffect::EnergyReward(energy_regen)) .with_requirement(CombatRequirement::AnyDamage); + let buff = CombatEffect::Buff(CombatBuff { + kind: BuffKind::Burning, + dur_secs: 5.0, + strength: CombatBuffStrength::DamageFraction(0.1 * buff_strength), + chance: 0.1, + }); let damage = AttackDamage::new( Damage { source: DamageSource::Explosion, @@ -151,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) @@ -164,6 +178,7 @@ impl ProjectileConstructor { ], radius, reagent: Some(Reagent::Red), + min_falloff, }; Projectile { hit_solid: vec![Effect::Explode(explosion.clone()), Effect::Vanish], @@ -175,7 +190,11 @@ impl ProjectileConstructor { is_point: true, } }, - Frostball { damage, radius } => { + Frostball { + damage, + radius, + min_falloff, + } => { let damage = AttackDamage::new( Damage { source: DamageSource::Explosion, @@ -192,6 +211,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 +223,11 @@ impl ProjectileConstructor { is_point: true, } }, - NecroticSphere { damage, radius } => { + NecroticSphere { + damage, + radius, + min_falloff, + } => { let damage = AttackDamage::new( Damage { source: DamageSource::Explosion, @@ -220,6 +244,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 +269,7 @@ impl ProjectileConstructor { damage, radius, knockback, + min_falloff, } => { let knockback = AttackEffect::new( Some(GroupTarget::OutOfGroup), @@ -272,6 +298,7 @@ impl ProjectileConstructor { ], radius, reagent: Some(Reagent::Red), + min_falloff, }; Projectile { hit_solid: vec![Effect::Explode(explosion.clone()), Effect::Vanish], @@ -283,7 +310,11 @@ impl ProjectileConstructor { is_point: true, } }, - Snowball { damage, radius } => { + Snowball { + damage, + radius, + min_falloff, + } => { let damage = AttackDamage::new( Damage { source: DamageSource::Explosion, @@ -299,6 +330,7 @@ impl ProjectileConstructor { effects: vec![RadiusEffect::Attack(attack)], radius, reagent: Some(Reagent::White), + min_falloff, }; Projectile { hit_solid: vec![], @@ -314,6 +346,7 @@ impl ProjectileConstructor { damage, radius, knockback, + min_falloff, } => { let knockback = AttackEffect::new( Some(GroupTarget::OutOfGroup), @@ -353,6 +386,7 @@ impl ProjectileConstructor { ], radius, reagent: Some(Reagent::Red), + min_falloff, }; Projectile { hit_solid: vec![Effect::Explode(explosion.clone()), Effect::Vanish], @@ -417,6 +451,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..8b98efce3e 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 { @@ -557,9 +558,19 @@ 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 - ((horiz_dist.max(vert_distance).max(0.0) / radius).min(1.0) - 1.0).abs() + // 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 = ((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) + } } // TODO: Faster RNG? @@ -714,7 +725,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 +818,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/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, }; 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, });