diff --git a/crates/horizon-client/src/game/raids.rs b/crates/horizon-client/src/game/raids.rs index bedca5708..4c5eff980 100644 --- a/crates/horizon-client/src/game/raids.rs +++ b/crates/horizon-client/src/game/raids.rs @@ -791,7 +791,7 @@ impl Game<'_> { let has_rider = ridden.contains(&m.id); let target_golem = matches!(m.ai.target, Some(horizon_client::mobs::Who::Mob(t)) if golems.contains(&t)); let target_player = m.ai.target == Some(horizon_client::mobs::Who::Player); - let (health, age, range) = (m.health, m.age, m.attrs.follow_range); + let (health, range) = (m.health, m.attrs.follow_range); let raids = &mut self.raiding.raids; let s = m.extra.raider.get_or_insert_with(Box::default); s.rider = has_rider; @@ -837,11 +837,9 @@ impl Game<'_> { { joins.push((m.id, id, health)); } - // PathfindToRaidGoal.recruitNearby. - if s.active_raid - && !s.raid_over - && !s.in_village - && age % 20 == 0 + // PathfindToRaidGoal.tick: recruitNearby, only while the goal runs. + if std::mem::take(&mut s.recruit_due) + && s.active_raid && let Some(id) = s.raid_id { recruit.push((id, position)); diff --git a/crates/horizon-client/src/mobs/raider.rs b/crates/horizon-client/src/mobs/raider.rs index 6c3ab9b64..6096d04ad 100644 --- a/crates/horizon-client/src/mobs/raider.rs +++ b/crates/horizon-client/src/mobs/raider.rs @@ -38,6 +38,9 @@ pub struct State { pub in_village: bool, /// A dropped ominous banner this raider may fetch. pub banner_at: Option<[f64; 3]>, + /// `PathfindToRaidGoal.tick` ran its 20 tick recruitment: the game + /// recruits the raiders around this one. + pub recruit_due: bool, /// Beds around the raid's centre. pub homes: Option>>, /// A ravager carrying a raider, set every tick from `Extra::rider`. @@ -114,7 +117,7 @@ pub fn register(m: &mut Mob) { m.extra.raider = Some(Box::default()); m.ai.goals.add(4, LongDistancePatrol::new(0.7, 0.595)); m.ai.goals.add(1, ObtainBanner); - m.ai.goals.add(3, PathfindToRaid); + m.ai.goals.add(3, PathfindToRaid::default()); m.ai.goals.add(4, MoveThroughVillage::new(1.05, 1.0)); m.ai.goals.add(5, Celebration); } @@ -357,9 +360,11 @@ impl Goal for ObtainBanner { } /// `PathfindToRaidGoal`: outside the village, head for the raid's centre in -/// hops of up to 15 blocks. -#[derive(Clone, Debug)] -pub struct PathfindToRaid; +/// hops of up to 15 blocks, recruiting nearby raiders every 20 ticks. +#[derive(Clone, Debug, Default)] +pub struct PathfindToRaid { + recruitment_tick: i32, +} impl PathfindToRaid { fn valid(s: &State) -> bool { s.active_raid && !s.raid_over && !s.in_village @@ -380,6 +385,12 @@ impl Goal for PathfindToRaid { let Some(c) = state(m).map(|s| s.raid_center) else { return; }; + if m.age as i32 > self.recruitment_tick { + self.recruitment_tick = m.age as i32 + 20; + if let Some(s) = m.extra.raider.as_deref_mut() { + s.recruit_due = true; + } + } if m.ai.nav.is_done() { let to = [ f64::from(c[0]) + 0.5,