Read the difficulty for a drowned's trident spread

RangedAttackMob.rangedAttackUncertainty is 14 - difficulty.getId() * 4, so a drowned
throws straighter the harder the world is. Horizon hard-coded the normal-difficulty 6,
which made every drowned as accurate as a hard-mode one on easy and peaceful.
This commit is contained in:
MSedgeMC committed 2026-11-01 17:50:43 +00:00
1 parent 41501a243a
commit 3217c6759b
1 file changed
+24 -1
+24 -1
View File
@@ -262,6 +262,13 @@ pub fn drowned_travel(
m.velocity = Vec3::new(m.velocity.x * 0.9, m.velocity.y * 0.9, m.velocity.z * 0.9);
true
}
/// `RangedAttackMob.rangedAttackUncertainty`: 14 on peaceful, four less per
/// difficulty step, so a hard drowned throws its trident almost straight.
/// `Drowned` overrides it to return its own field when that is not negative,
/// but nothing in the game sets that field, so the default always applies.
fn ranged_attack_uncertainty(difficulty: u8) -> f32 {
14.0 - 4.0 * f32::from(difficulty)
}
/// The trident throw of `Drowned.performRangedAttack`: a `ThrownTrident` of
/// the held trident (a plain one when it holds none), owned by the drowned,
/// which cannot be picked up and does not return (`AbstractArrow` constructor:
@@ -291,7 +298,7 @@ fn drowned_throw(m: &mut Mob, who: Who, _power: f32, cx: &mut Cx) {
&mut crate::projectiles::own_random(m),
[xd, yd + dist * f64::from(0.2_f32), zd],
1.6,
(14 - 2 * 4) as f32,
ranged_attack_uncertainty(cx.w.difficulty.id),
);
cx.events.push(MobEvent::Projectile(p));
let pitch = 1.0 / (m.random.next_float() * 0.4 + 0.8);
@@ -1353,3 +1360,19 @@ mod conversion_tests {
assert_eq!(z.extra.feet.as_deref(), Some("minecraft:golden_boots"));
}
}
#[cfg(test)]
mod trident_tests {
use super::ranged_attack_uncertainty;
/// `RangedAttackMob.rangedAttackUncertainty` is 14 minus four per
/// difficulty step, so a drowned's trident spread shrinks from 14 on
/// peaceful to 2 on hard. Horizon used to hard-code the normal value.
#[test]
fn the_trident_spread_follows_the_difficulty() {
assert_eq!(ranged_attack_uncertainty(0), 14.0, "peaceful");
assert_eq!(ranged_attack_uncertainty(1), 10.0, "easy");
assert_eq!(ranged_attack_uncertainty(2), 6.0, "normal");
assert_eq!(ranged_attack_uncertainty(3), 2.0, "hard");
}
}