From f9fca5688d079b797eb77aca2a5bf5282d0e6f40 Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Tue, 27 Oct 2026 22:17:23 +0100 Subject: [PATCH] Give witches their resistance to magic Witch.getDamageAfterMagicAbsorb takes 85% off #witch_resistant_to (magic, indirect_magic, sonic_boom, thorns) and all of the witch's own damage; Horizon had no such rule. --- crates/horizon-client/src/game/potions.rs | 6 ++++-- crates/horizon-client/src/mobs.rs | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/crates/horizon-client/src/game/potions.rs b/crates/horizon-client/src/game/potions.rs index affd68782..635277ff8 100644 --- a/crates/horizon-client/src/game/potions.rs +++ b/crates/horizon-client/src/game/potions.rs @@ -960,7 +960,8 @@ impl Game<'_> { let amount = |base: i32| (0.5 * f64::from(base << amp) + 0.5) as i32 as f32; if (*id == "instant_damage") != inverted { - m.hurt(amount(6), Some(at), &mut self.world.random); + let harm = m.potion_harm(amount(6)); + m.hurt(harm, Some(at), &mut self.world.random); } else { m.health = (m.health + amount(4)).min(m.kind.max_health); } @@ -1228,8 +1229,9 @@ impl Game<'_> { }; let m = &mut self.mobs[i]; if harm { + let harm = m.potion_harm((intensity * f64::from(6 << amp) + 0.5) as i32 as f32); m.hurt( - (intensity * f64::from(6 << amp) + 0.5) as i32 as f32, + harm, Some([at.x, at.y, at.z]), &mut self.world.random, ); diff --git a/crates/horizon-client/src/mobs.rs b/crates/horizon-client/src/mobs.rs index db617e7c9..f42f915ad 100644 --- a/crates/horizon-client/src/mobs.rs +++ b/crates/horizon-client/src/mobs.rs @@ -2085,6 +2085,18 @@ impl Mob { if epf > 0.0 { amount *= 1.0 - epf / 25.0; } + // Witch.getDamageAfterMagicAbsorb: none from its own doing, else + // 85% less from `#witch_resistant_to`. + if self.species() == Species::Witch { + if source.attacker == Some(Who::Mob(self.id)) { + amount = 0.0; + } else if matches!( + source.kind, + DamageKind::Magic | DamageKind::SonicBoom | DamageKind::Thorns + ) { + amount *= 0.15; + } + } // Wolf.actuallyHurt: wolf armor takes the damage instead of the wolf. let absorbed = self.wolf_armor_absorbs(&source); let mut knock = true; @@ -2167,6 +2179,15 @@ impl Mob { } true } + /// A splash or cloud's harming effect on this mob: the potion's + /// `indirect_magic` is in `#witch_resistant_to`, so a witch takes 15%. + pub fn potion_harm(&self, amount: f32) -> f32 { + if self.species() == Species::Witch { + amount * 0.15 + } else { + amount + } + } /// `Wolf.canArmorAbsorb`: it wears wolf armor and the damage type is not /// in `#bypasses_wolf_armor` (drowning, magic, thorns, in a wall, out of /// the world and the untyped kills).