mirror of
https://github.com/horizon-rust/horizon.git
synced 2026-11-07 17:21:49 -10:00
Give an endermite its own goal list
Endermite.registerGoals is the silverfish-style monster list: powder-snow climbing, a melee attack, a stroll at 1.0, and a HurtByTargetGoal that alerts the others. Horizon never put the endermite in the hostile family, so it fell back to the generic monster block: stroll at 0.8, no powder-snow climb, and a hurt-by-target goal that never alerts.
This commit is contained in:
1 parent
1bd24e4042
commit
38f7febdc4
2 files changed
+45
-1
No files matched your search
@@ -193,7 +193,7 @@ pub fn family(s: Species) -> Family {
|
||||
| S::Parched
|
||||
| S::WitherSkeleton
|
||||
| S::ZombifiedPiglin => Family::Undead,
|
||||
S::Creeper | S::Spider | S::CaveSpider | S::Silverfish => Family::Hostile,
|
||||
S::Creeper | S::Spider | S::CaveSpider | S::Silverfish | S::Endermite => Family::Hostile,
|
||||
S::Squid
|
||||
| S::GlowSquid
|
||||
| S::Cod
|
||||
@@ -3122,6 +3122,37 @@ mod forgiveness_tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod endermite_goal_tests {
|
||||
use super::*;
|
||||
use crate::mobs::world::with_test_world;
|
||||
|
||||
/// `Endermite.registerGoals` is the silverfish's family list without the
|
||||
/// stone tricks: a powder-snow climb, a stroll at 1.0 and a
|
||||
/// `HurtByTargetGoal` that alerts the others. The generic monster block
|
||||
/// an unlisted species gets has none of those (stroll 0.8, no alert).
|
||||
#[test]
|
||||
fn an_endermite_takes_the_hostile_goal_list() {
|
||||
let ran = with_test_world(&[], |_, types| {
|
||||
let m = Mob::new(
|
||||
1,
|
||||
std::sync::Arc::new(types.types["minecraft:endermite"].clone()),
|
||||
Vec3::ZERO,
|
||||
0.0,
|
||||
);
|
||||
assert_eq!(family(m.species()), Family::Hostile);
|
||||
assert!(
|
||||
m.ai.goals.has("ClimbOnTopOfPowderSnow"),
|
||||
"ClimbOnTopOfPowderSnowGoal"
|
||||
);
|
||||
assert!(m.ai.goals.has("Stroll"), "WaterAvoidingRandomStrollGoal");
|
||||
assert!(m.ai.targets.has("HurtByTarget"));
|
||||
assert!(m.ai.targets.has("NearestTarget"));
|
||||
});
|
||||
let _ = ran;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod fox_screech_tests {
|
||||
use super::*;
|
||||
|
||||
@@ -64,6 +64,19 @@ pub fn register(m: &mut Mob) {
|
||||
m.ai.targets.add(1, HurtByTarget::new().alert());
|
||||
m.ai.targets.add(2, NearestTarget::player(true));
|
||||
}
|
||||
// Endermite.registerGoals: the silverfish's list without the stone
|
||||
// tricks, at vanilla's priorities (stroll 1.0, alert others on hurt).
|
||||
S::Endermite => {
|
||||
let g = &mut m.ai.goals;
|
||||
g.add(1, Float);
|
||||
g.add(1, ClimbOnTopOfPowderSnow);
|
||||
g.add(2, MeleeAttack::new(1.0, false));
|
||||
g.add(3, Stroll::avoiding_water(1.0));
|
||||
g.add(7, LookAtPlayer::new(8.0));
|
||||
g.add(8, RandomLookAround::default());
|
||||
m.ai.targets.add(1, HurtByTarget::new().alert());
|
||||
m.ai.targets.add(2, NearestTarget::player(true));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user