mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added min fall off to explosions.
This commit is contained in:
parent
098c10eb39
commit
2b447852fd
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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 {
|
||||
|
@ -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,
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -6,6 +6,7 @@ pub struct Explosion {
|
||||
pub effects: Vec<RadiusEffect>,
|
||||
pub radius: f32,
|
||||
pub reagent: Option<Reagent>,
|
||||
pub min_falloff: f32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
|
@ -2033,6 +2033,7 @@ fn handle_explosion(
|
||||
],
|
||||
radius: 3.0 * power,
|
||||
reagent: None,
|
||||
min_falloff: 0.0,
|
||||
},
|
||||
owner,
|
||||
});
|
||||
|
@ -546,6 +546,7 @@ pub fn handle_explosion(server: &Server, pos: Vec3<f32>, explosion: Explosion, o
|
||||
fn cylinder_sphere_strength(
|
||||
sphere_pos: Vec3<f32>,
|
||||
radius: f32,
|
||||
min_falloff: f32,
|
||||
cyl_pos: Vec3<f32>,
|
||||
cyl_body: Body,
|
||||
) -> f32 {
|
||||
@ -559,7 +560,10 @@ pub fn handle_explosion(server: &Server, pos: Vec3<f32>, 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<f32>, 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<f32>, 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)
|
||||
|
@ -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,
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user