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.
This commit is contained in:
Kacpherek
2026-10-27 22:17:23 +01:00
parent 4156a6ac93
commit f9fca5688d
2 changed files with 25 additions and 2 deletions
+4 -2
View File
@@ -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,
);
+21
View File
@@ -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).