Merge pull request #2195 from kacpherek/fix/guardian-beam-rules
🤖 Agent: Gate check by Ludovic's AI agent (Claude). Checked against 26.3: the guardian's beam deals 2 more on Hard and 2 more from an elder, and squid and axolotl targets must be over 3 blocks away (`GuardianAttackSelector`). Gate: this wave's 55 PRs merged on main in one tree: clippy `-D warnings` clean, 1186 horizon-client and 163 horizon-world tests pass, and of the 101 harnesses `parity.py --changed-files` picked, 100 pass (`block_removal` failed on one spawner case from #2199's orb merging, fixed there). `lan_e2e.py` passes 24 checks with the host on its server thread and in-frame (chest, xp, pvp, doors, villagers, beds, frames, projectiles, arrows, fishing, damage, mobs, blast, drops, elytra, breath, predict, cracks, barter, kills, hurt, contacts, underwater, plates), plus forced-levels on the server thread. Thanks @kacpherek!
This commit is contained in:
@@ -1210,6 +1210,9 @@ pub struct NearestTarget {
|
||||
pub interval: i32,
|
||||
/// Extra condition on the attacker, checked after the random interval.
|
||||
pub when: Option<fn(&Mob, &MobWorld) -> bool>,
|
||||
/// Mobs closer than this squared distance are not picked
|
||||
/// (`GuardianAttackSelector`: `distanceToSqr > 9`).
|
||||
pub beyond_sqr: Option<f64>,
|
||||
/// A condition checked before anything else, by subclasses overriding
|
||||
/// `canUse` (SpiderTargetGoal: only in the dark).
|
||||
pub gate: Option<fn(&Mob, &MobWorld) -> bool>,
|
||||
@@ -1242,6 +1245,7 @@ impl NearestTarget {
|
||||
must_reach: false,
|
||||
interval: reduced(10),
|
||||
when: None,
|
||||
beyond_sqr: None,
|
||||
gate: None,
|
||||
label: None,
|
||||
found: None,
|
||||
@@ -1274,6 +1278,10 @@ impl NearestTarget {
|
||||
self.when = Some(f);
|
||||
self
|
||||
}
|
||||
pub fn beyond(mut self, distance_sqr: f64) -> Self {
|
||||
self.beyond_sqr = Some(distance_sqr);
|
||||
self
|
||||
}
|
||||
pub fn gate(mut self, f: fn(&Mob, &MobWorld) -> bool) -> Self {
|
||||
self.gate = Some(f);
|
||||
self
|
||||
@@ -1361,6 +1369,9 @@ impl Goal for NearestTarget {
|
||||
if m.distance_sqr(cpos) > range * range {
|
||||
continue;
|
||||
}
|
||||
if self.beyond_sqr.is_some_and(|d| m.distance_sqr(cpos) <= d) {
|
||||
continue;
|
||||
}
|
||||
if !m.sees(cx.w, Who::Mob(cid)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,8 @@ pub fn register(m: &mut Mob) {
|
||||
NearestTarget::species(
|
||||
&[Species::Squid, Species::GlowSquid, Species::Axolotl],
|
||||
true,
|
||||
),
|
||||
)
|
||||
.beyond(9.0),
|
||||
);
|
||||
}
|
||||
/// `GuardianAttackGoal`.
|
||||
@@ -120,9 +121,11 @@ impl Goal for GuardianAttack {
|
||||
1.0,
|
||||
));
|
||||
} else if self.attack_time >= attack_duration(m) {
|
||||
// Indirect magic (1, +2 for the elder; NORMAL difficulty), then
|
||||
// Indirect magic (1, +2 on Hard, +2 for the elder), then
|
||||
// doHurtTarget.
|
||||
let magic = if is_elder(m) { 3.0 } else { 1.0 };
|
||||
let magic = 1.0
|
||||
+ if cx.w.difficulty.hard { 2.0 } else { 0.0 }
|
||||
+ if is_elder(m) { 2.0 } else { 0.0 };
|
||||
let from = [m.position.x, m.position.y, m.position.z];
|
||||
match who {
|
||||
Who::Player => cx.events.push(MobEvent::DamagePlayer {
|
||||
|
||||
Reference in New Issue
Block a user