From 4c8ff0296988236ff4b33e83b082a4892228a794 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 18:51:03 +0100 Subject: [PATCH] Make skeleton arrow spread and damage follow the difficulty --- crates/horizon-client/src/mobs/spawning.rs | 4 ++++ crates/horizon-client/src/mobs/undead.rs | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/horizon-client/src/mobs/spawning.rs b/crates/horizon-client/src/mobs/spawning.rs index 93e3fe119..5d8a928f8 100644 --- a/crates/horizon-client/src/mobs/spawning.rs +++ b/crates/horizon-client/src/mobs/spawning.rs @@ -34,6 +34,8 @@ pub fn placement_ok(species: Species, w: &MobWorld, x: i32, y: i32, z: i32) -> b /// `DifficultyInstance`: the local difficulty at a position. #[derive(Clone, Copy, Debug)] pub struct LocalDifficulty { + /// `Difficulty.getId`: 0 peaceful to 3 hard. + pub id: u8, pub effective: f32, /// The world difficulty is hard. pub hard: bool, @@ -47,6 +49,7 @@ impl LocalDifficulty { let hard = base == 3; if base == 0 { return Self { + id: base, effective: 0.0, hard, }; @@ -59,6 +62,7 @@ impl LocalDifficulty { local *= 0.5; } Self { + id: base, effective: f32::from(base) * (0.75 + global + local), hard, } diff --git a/crates/horizon-client/src/mobs/undead.rs b/crates/horizon-client/src/mobs/undead.rs index e77a37641..1fcea9c12 100644 --- a/crates/horizon-client/src/mobs/undead.rs +++ b/crates/horizon-client/src/mobs/undead.rs @@ -743,8 +743,9 @@ pub fn perform_ranged_attack(m: &mut Mob, who: Who, cx: &mut Cx, power: f32) { let zd = t.position.z - m.position.z; let dist = (xd * xd + zd * zd).sqrt(); // AbstractArrow.setBaseDamageFromMob: power * 2 + triangle(difficulty * 0.11, 0.57425). + let id = i32::from(cx.w.difficulty.id); let mut arrow_random = crate::projectiles::own_random(m); - let base = f64::from(power) * 2.0 + arrow_random.triangle(2.0 * 0.11, 0.574_25); + let base = f64::from(power) * 2.0 + arrow_random.triangle(f64::from(id) * 0.11, 0.574_25); let effect = match m.species() { Species::Stray => Some(("minecraft:slowness", 600)), Species::Bogged => Some(("minecraft:poison", 100)), @@ -765,7 +766,7 @@ pub fn perform_ranged_attack(m: &mut Mob, who: Who, cx: &mut Cx, power: f32) { &mut arrow_random, [xd, yd + dist * 0.2, zd], 1.6, - (14 - 2 * 4) as f32, + (14 - id * 4) as f32, ); cx.events.push(MobEvent::Projectile(p)); let pitch = 1.0 / (m.random.next_float() * 0.4 + 0.8);