Browse Source

simplified mob aI

lakebane
FatBoy-DOTC 4 weeks ago
parent
commit
9c623f277b
  1. 25
      src/engine/mobileAI/Behaviours/StandardMob.java

25
src/engine/mobileAI/Behaviours/StandardMob.java

@ -16,16 +16,17 @@ import java.util.HashSet; @@ -16,16 +16,17 @@ import java.util.HashSet;
public class StandardMob {
public static void run(Mob mob){
if(!mob.isAlive()){
CheckForRespawn(mob);
return;
}
HashSet<AbstractWorldObject> inRange = WorldGrid.getObjectsInRangePartial(mob.loc, MBServerStatics.CHARACTER_LOAD_RANGE, MBServerStatics.MASK_PLAYER);
if(inRange.isEmpty())
return;
if(!mob.isAlive()){
CheckForRespawn(mob);
return;
}
if (mob.isMoving()) {
mob.setLoc(mob.getMovementLoc());
mob.updateLocation();
@ -78,7 +79,6 @@ public class StandardMob { @@ -78,7 +79,6 @@ public class StandardMob {
}
if (!mob.despawned) {
if (mob.getCharItemManager().getInventoryCount() > 0) {
if (System.currentTimeMillis() > mob.deathTime + MBServerStatics.DESPAWN_TIMER_WITH_LOOT) {
mob.despawn();
@ -193,9 +193,18 @@ public class StandardMob { @@ -193,9 +193,18 @@ public class StandardMob {
if(mob.combatTarget != null){
//chase player
if(!CombatUtilities.inRange2D(mob,mob.combatTarget,mob.getRange())) {
if(mob.combatTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
PlayerCharacter target = (PlayerCharacter)mob.combatTarget;
if(target.isMoving()){
MovementUtilities.aiMove(mob, mob.combatTarget.loc, false);
return;
}else{
Vector3fImmutable smoothLoc = Vector3fImmutable.getRandomPointOnCircle(mob.combatTarget.loc,mob.getRange() -1);
MovementUtilities.aiMove(mob, smoothLoc, false);
return;
}
}
MovementUtilities.aiMove(mob, mob.combatTarget.loc, false);
}else{
mob.stopMovement(mob.getMovementLoc());
}
}else{
@ -228,8 +237,6 @@ public class StandardMob { @@ -228,8 +237,6 @@ public class StandardMob {
if(!CombatUtilities.inRange2D(mob,mob.combatTarget,mob.getRange()))
return;
mob.updateLocation();
//InterestManager.forceLoad(mob);
InterestManager.setObjectDirty(mob);
if (mainHand == null && offHand == null) {

Loading…
Cancel
Save