Make skeleton arrow spread and damage follow the difficulty

This commit is contained in:
Kacpherek
2026-10-26 18:51:03 +01:00
parent 0b98555009
commit 4c8ff02969
2 changed files with 7 additions and 2 deletions
@@ -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,
}
+3 -2
View File
@@ -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);