Improved basilisk AI MOREE
This commit is contained in:
1 parent
9784c0ed62
commit
4412599258
1 file changed
+34
-5
+34
-5
@@ -80,6 +80,7 @@ public class BasiliskEntity extends Monster implements GeoEntity {
|
|||||||
|
|
||||||
private int attackAnimTicks = 0;
|
private int attackAnimTicks = 0;
|
||||||
private boolean attackDamagePending = false;
|
private boolean attackDamagePending = false;
|
||||||
|
private int attackCooldown = 0;
|
||||||
|
|
||||||
private int hissCooldown = AntarchySettings.basiliskHissCooldownTicks();
|
private int hissCooldown = AntarchySettings.basiliskHissCooldownTicks();
|
||||||
private int hissChargeTimer = 0;
|
private int hissChargeTimer = 0;
|
||||||
@@ -219,6 +220,7 @@ public class BasiliskEntity extends Monster implements GeoEntity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.attackCooldown > 0) this.attackCooldown--;
|
||||||
this.tickPlayerPetrification();
|
this.tickPlayerPetrification();
|
||||||
this.tickPreyPetrification();
|
this.tickPreyPetrification();
|
||||||
this.tickAoeDamage();
|
this.tickAoeDamage();
|
||||||
@@ -447,6 +449,7 @@ public class BasiliskEntity extends Monster implements GeoEntity {
|
|||||||
this.setAnimationState(ANIM_DEATH);
|
this.setAnimationState(ANIM_DEATH);
|
||||||
this.attackAnimTicks = 0;
|
this.attackAnimTicks = 0;
|
||||||
this.attackDamagePending = false;
|
this.attackDamagePending = false;
|
||||||
|
this.attackCooldown = 0;
|
||||||
this.hissChargeTimer = 0;
|
this.hissChargeTimer = 0;
|
||||||
this.pendingTargetId = null;
|
this.pendingTargetId = null;
|
||||||
this.getNavigation().stop();
|
this.getNavigation().stop();
|
||||||
@@ -558,6 +561,11 @@ public class BasiliskEntity extends Monster implements GeoEntity {
|
|||||||
super(mob);
|
super(mob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Call this to prevent the move control from reapplying speed this tick. */
|
||||||
|
public void halt() {
|
||||||
|
this.operation = MoveControl.Operation.WAIT;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
if (this.operation == MoveControl.Operation.MOVE_TO) {
|
if (this.operation == MoveControl.Operation.MOVE_TO) {
|
||||||
@@ -596,25 +604,44 @@ public class BasiliskEntity extends Monster implements GeoEntity {
|
|||||||
BasiliskEntity.this.getLookControl().setLookAt(target, 30.0F, 30.0F);
|
BasiliskEntity.this.getLookControl().setLookAt(target, 30.0F, 30.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// super handles path recalc and cooldown timer — always run it
|
||||||
|
super.tick();
|
||||||
|
|
||||||
if (BasiliskEntity.this.hissChargeTimer > 0 || BasiliskEntity.this.attackAnimTicks > 0) {
|
if (BasiliskEntity.this.hissChargeTimer > 0 || BasiliskEntity.this.attackAnimTicks > 0) {
|
||||||
this.stopMovement();
|
this.stopMovement();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
super.tick();
|
|
||||||
|
|
||||||
// If we're in range after super ran, kill movement so the basilisk stops and bites
|
|
||||||
if (target != null && BasiliskEntity.this.isWithinMeleeAttackRange(target)) {
|
if (target != null && BasiliskEntity.this.isWithinMeleeAttackRange(target)) {
|
||||||
this.stopMovement();
|
this.stopMovement();
|
||||||
|
this.checkAndPerformAttack(target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopMovement() {
|
private void stopMovement() {
|
||||||
BasiliskEntity.this.getNavigation().stop();
|
BasiliskEntity.this.getNavigation().stop();
|
||||||
|
((BasiliskMoveControl) BasiliskEntity.this.getMoveControl()).halt();
|
||||||
BasiliskEntity.this.setSpeed(0.0F);
|
BasiliskEntity.this.setSpeed(0.0F);
|
||||||
BasiliskEntity.this.setZza(0.0F);
|
BasiliskEntity.this.setZza(0.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUse() {
|
||||||
|
LivingEntity target = BasiliskEntity.this.getTarget();
|
||||||
|
if (target == null || !target.isAlive()) return false;
|
||||||
|
if (target instanceof Player p && (p.isCreative() || p.isSpectator())) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start() {
|
||||||
|
LivingEntity target = BasiliskEntity.this.getTarget();
|
||||||
|
if (target != null) {
|
||||||
|
BasiliskEntity.this.getNavigation().moveTo(target, 1.2D);
|
||||||
|
}
|
||||||
|
BasiliskEntity.this.setAggressive(true);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canContinueToUse() {
|
public boolean canContinueToUse() {
|
||||||
return BasiliskEntity.this.attackAnimTicks > 0 || super.canContinueToUse();
|
return BasiliskEntity.this.attackAnimTicks > 0 || super.canContinueToUse();
|
||||||
@@ -623,9 +650,11 @@ public class BasiliskEntity extends Monster implements GeoEntity {
|
|||||||
@Override
|
@Override
|
||||||
protected void checkAndPerformAttack(LivingEntity target) {
|
protected void checkAndPerformAttack(LivingEntity target) {
|
||||||
if (BasiliskEntity.this.attackAnimTicks > 0) return;
|
if (BasiliskEntity.this.attackAnimTicks > 0) return;
|
||||||
if (!this.canPerformAttack(target)) return;
|
if (BasiliskEntity.this.attackCooldown > 0) return;
|
||||||
|
if (!BasiliskEntity.this.isWithinMeleeAttackRange(target)) return;
|
||||||
|
if (!BasiliskEntity.this.getSensing().hasLineOfSight(target)) return;
|
||||||
|
|
||||||
this.resetAttackCooldown();
|
BasiliskEntity.this.attackCooldown = 20;
|
||||||
BasiliskEntity.this.performAoeAttack();
|
BasiliskEntity.this.performAoeAttack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user