Guardians: damage scales with Hard and elders, squid and axolotls must be beyond 3 blocks
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