Let witches heal raiders and name the ominous banner
During a raid a witch looks for the other raiders, throws them Regeneration, or Healing once they are almost dead, and the potion cloud heals every raider it reaches. The ominous banner shows its own name and uncommon rarity in tooltips. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1636,6 +1636,32 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
}
|
||||
// A witch's healing potions reach the raiders around the splash.
|
||||
if matches!(
|
||||
*effect,
|
||||
"minecraft:instant_health" | "minecraft:regeneration"
|
||||
) {
|
||||
let center = at;
|
||||
for m in &mut self.mobs {
|
||||
let d2 = m.position.distance_squared(center);
|
||||
if !m.alive()
|
||||
|| d2 >= 16.0
|
||||
|| !horizon_client::mobs::raider::is_raider(m.species())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
let scale = 1.0 - d2.sqrt() / 4.0;
|
||||
if *effect == "minecraft:instant_health" {
|
||||
let heal = (4 << *amplifier) as f64 * scale;
|
||||
m.health = (m.health + heal as f32).min(m.attrs.max_health);
|
||||
} else {
|
||||
let t = (f64::from(*ticks) * scale + 0.5) as i32;
|
||||
if t > 20 {
|
||||
m.add_effect(effect, t, *amplifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
self.audio.play(
|
||||
"minecraft:entity.splash_potion.break",
|
||||
Some(atp),
|
||||
|
||||
@@ -1725,6 +1725,10 @@ impl Game<'_> {
|
||||
let e: &Enchantments = &self.res.stations.enchantments;
|
||||
let props = e.props(&stack.item);
|
||||
let mut rarity = props.map_or("common", |p| p.rarity.as_str());
|
||||
// The ominous banner's rarity component.
|
||||
if stack.data().is_some_and(|d| d.ominous_banner) {
|
||||
rarity = "uncommon";
|
||||
}
|
||||
if !stack.enchantments().is_empty() {
|
||||
rarity = match rarity {
|
||||
"common" | "uncommon" => "rare",
|
||||
@@ -1740,6 +1744,9 @@ impl Game<'_> {
|
||||
};
|
||||
let name = if let Some(n) = stack.custom_name() {
|
||||
n.to_owned()
|
||||
} else if stack.data().is_some_and(|d| d.ominous_banner) {
|
||||
e.translate("block.minecraft.ominous_banner")
|
||||
.map_or_else(|| "Ominous Banner".to_owned(), str::to_owned)
|
||||
} else if stack.data().and_then(|d| d.potion.as_ref()).is_some()
|
||||
|| stack.item.ends_with("potion")
|
||||
|| &*stack.item == "minecraft:tipped_arrow"
|
||||
|
||||
@@ -19,6 +19,18 @@ pub fn register(m: &mut Mob) {
|
||||
g.add(3, LookAtPlayer::new(8.0));
|
||||
g.add(3, RandomLookAround::default());
|
||||
m.ai.targets.add(1, HurtByTarget::new());
|
||||
// NearestHealableRaiderTargetGoal: in a raid, go and heal the other raiders.
|
||||
m.ai.targets.add(
|
||||
2,
|
||||
NearestTarget::new(
|
||||
super::goals::Prey::Filter(|s| {
|
||||
super::raider::is_raider(s.species) && s.species != Species::Witch
|
||||
}),
|
||||
true,
|
||||
)
|
||||
.interval(1)
|
||||
.when(|m, _| super::raider::has_active_raid(m)),
|
||||
);
|
||||
m.ai.targets
|
||||
.add(3, NearestTarget::player(true).interval(10));
|
||||
}
|
||||
@@ -129,7 +141,23 @@ fn witch_attack(m: &mut Mob, who: Who, _power: f32, cx: &mut Cx) {
|
||||
})
|
||||
.map_or(20.0, |s| s.health)
|
||||
};
|
||||
let (effect, ticks, amplifier) = if dist >= 8.0 {
|
||||
// A raider target is healed instead: Healing when nearly dead, else
|
||||
// Regeneration, and the witch drops the target afterwards.
|
||||
let heals = match who {
|
||||
Who::Mob(id) => {
|
||||
cx.w.seen(id)
|
||||
.is_some_and(|s| super::raider::is_raider(s.species))
|
||||
}
|
||||
Who::Player => false,
|
||||
};
|
||||
let (effect, ticks, amplifier) = if heals {
|
||||
m.ai.target = None;
|
||||
if health <= 4.0 {
|
||||
("minecraft:instant_health", 1, 0)
|
||||
} else {
|
||||
("minecraft:regeneration", 900, 0)
|
||||
}
|
||||
} else if dist >= 8.0 {
|
||||
("minecraft:slowness", 1800, 0)
|
||||
} else if health >= 8.0 {
|
||||
("minecraft:poison", 900, 0)
|
||||
|
||||
Reference in New Issue
Block a user