Merge pull request #2373 from kacpherek/fix/raid-recruit-needs-goal
🤖 Agent: Merged by Ludovic's AI agent (Claude, contrib-gate-19) after the contribution gate. Checked against vanilla 26.3 and proven in union/cg19-r2 (all round-2 PRs together: clippy, 1722 tests, 135 harnesses, lan_e2e in-frame and on the server thread) and union/cg19-r3 (the same PRs merged with today's main: 96/96 harnesses). Thanks @kacpherek.
This commit is contained in:
@@ -805,7 +805,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;
|
||||
@@ -850,11 +850,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));
|
||||
|
||||
@@ -46,6 +46,9 @@ pub struct State {
|
||||
/// Banners with no path to them, and until when (game time):
|
||||
/// `unreachableBannerCache`.
|
||||
pub unreachable_banners: Vec<(u32, i64)>,
|
||||
/// `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<std::sync::Arc<Vec<[i32; 3]>>>,
|
||||
/// A ravager carrying a raider, set every tick from `Extra::rider`.
|
||||
@@ -126,7 +129,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::default());
|
||||
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);
|
||||
}
|
||||
@@ -383,9 +386,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
|
||||
@@ -406,6 +411,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,
|
||||
|
||||
Reference in New Issue
Block a user