Swing a horse's tail now and then

This commit is contained in:
Kacpherek
2026-10-26 20:30:33 +01:00
parent 55a71d3502
commit 82d2b61a4a
3 changed files with 36 additions and 2 deletions
+10
View File
@@ -3507,6 +3507,16 @@ impl Game<'_> {
if m.species() == horizon_client::mobs::Species::Rabbit {
horizon_client::mobs::rabbit::base_tick(m);
}
if matches!(
m.species(),
horizon_client::mobs::Species::Horse
| horizon_client::mobs::Species::Donkey
| horizon_client::mobs::Species::Mule
| horizon_client::mobs::Species::SkeletonHorse
| horizon_client::mobs::Species::ZombieHorse
) {
horizon_client::mobs::equine::tail_tick(m);
}
if m.species() == horizon_client::mobs::Species::Creeper {
horizon_client::mobs::hostile::creeper_client_tick(m);
}
+1 -1
View File
@@ -641,7 +641,7 @@ fn ai_step(m: &mut Mob, w: &MobWorld, level_random: &mut LegacyRandom, events: &
}
// AbstractHorse.aiStep: the tail swishes now and then (moveTail).
if super::equine::is_equine(m.species()) {
let _ = m.random.next_int_bound(200);
super::equine::tail_tick(m);
}
// Monster.aiStep: updateNoActionTime (Raider: always +2).
if is_monster(m.species())
+25 -1
View File
@@ -28,6 +28,8 @@ pub const MARKINGS: [&str; 5] = ["", "white", "whitefield", "whitedots", "blackd
pub const EAT: usize = 0;
pub const STAND: usize = 1;
pub const MOUTH: usize = 2;
/// `AbstractHorse.tailCounter`: client-side, it only drives the model.
pub const TAIL: usize = 3;
/// What a rider asks of its mount this tick.
#[derive(Clone, Copy, Debug, Default)]
@@ -418,6 +420,20 @@ pub fn ridden_step(m: &mut Mob) {
}
}
}
/// `AbstractHorse.aiStep`'s `moveTail` (one in 200 ticks) and the counter's
/// step in `tick` (it runs to 8, then stops). A client runs it on its own
/// random, as vanilla's client-side `aiStep` does.
pub fn tail_tick(m: &mut Mob) {
if m.random.next_int_bound(200).unwrap_or(1) == 0 {
m.anim.v[TAIL] = 1.0;
}
if m.anim.v[TAIL] > 0.0 {
m.anim.v[TAIL] += 1.0;
if m.anim.v[TAIL] > 8.0 {
m.anim.v[TAIL] = 0.0;
}
}
}
/// `AbstractHorse.aiStep` and `tick`: healing, grazing, the rear and the
/// eating/standing/mouth animations.
pub fn ai_step(m: &mut Mob, w: &MobWorld, events: &mut Vec<MobEvent>) {
@@ -603,7 +619,15 @@ pub fn anim(m: &Mob, s: &State, p: &mut Poses) {
t[1] += speed * age;
t[2] += speed * 2.0 * age;
}
p.yrot("tail", 0.0);
// animateTail: the tail swings while the counter runs.
p.yrot(
"tail",
if m.anim.v[TAIL] > 0.0 {
(s.age * 0.7).mcos()
} else {
0.0
},
);
if baby && donkey {
// BabyDonkeyModel overrides the state's pitch with -30 degrees and
// sets the head parts again.