aboutsummaryrefslogtreecommitdiffstats
path: root/src/server.rs
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2024-03-20 06:39:46 +0100
committerLibravatar Alexander Foremny <aforemny@posteo.de>2024-03-20 06:45:22 +0100
commit716bd0618308d6100556d1231b0b156f48c64778 (patch)
tree9ba09552391330c9bcee2b71d42928234b3ec6ea /src/server.rs
parent0165c47ea6c002c4eb177289ced5412b73273a25 (diff)
feat: scale spear damage
Diffstat (limited to 'src/server.rs')
-rw-r--r--src/server.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/server.rs b/src/server.rs
index 1b31338..5ac07c0 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -474,12 +474,28 @@ fn projectile_despawn(
if let Some(target_player) = maybe_target_player {
if let Some(target_entity) = entity_map.0.get(&target_player.0) {
if let Ok(mut health) = healths.get_mut(*target_entity) {
- health.apply_damage(projectile.damage);
+ let damage = match projectile.type_ {
+ ProjectileType::Free(FreeProjectile {
+ position,
+ starting_position,
+ max_distance,
+ scale_damage: Some((min_multiplier, max_multiplier)),
+ ..
+ }) => {
+ let distance_traveled =
+ position.distance(starting_position) / max_distance;
+ let multiplier =
+ min_multiplier.lerp(max_multiplier, distance_traveled);
+ multiplier * projectile.damage
+ }
+ _ => projectile.damage,
+ };
+ health.apply_damage(damage);
let _ = connection_manager
.send_message_to_target::<Channel1, HealthChanged>(
HealthChanged(HealthEvent {
target_player,
- health_gained: -projectile.damage,
+ health_gained: -damage,
}),
NetworkTarget::All,
);