Browse Source

simplified mob aI

lakebane
FatBoy-DOTC 1 month ago
parent
commit
89b5ebe7aa
  1. 17
      src/engine/mobileAI/Behaviours/StandardMob.java

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

@ -33,13 +33,11 @@ public class StandardMob {
if(mob.combatTarget == null) { if(mob.combatTarget == null) {
if (!inRange.isEmpty()) { if (!inRange.isEmpty()) {
CheckForAggro(mob); CheckForAggro(mob);
return;
} }
}else{ }else{
CheckToDropCombatTarget(mob); CheckToDropCombatTarget(mob);
if(mob.combatTarget == null){ if(mob.combatTarget == null){
CheckForAggro(mob); CheckForAggro(mob);
return;
} }
} }
@ -146,7 +144,7 @@ public class StandardMob {
} }
//find most hated target //find most hated target
PlayerCharacter mostHated = (PlayerCharacter)inRange.iterator().next(); PlayerCharacter mostHated = null;
for(AbstractWorldObject awo : inRange){ for(AbstractWorldObject awo : inRange){
PlayerCharacter loadedPlayer = (PlayerCharacter)awo; PlayerCharacter loadedPlayer = (PlayerCharacter)awo;
if (loadedPlayer == null) if (loadedPlayer == null)
@ -168,6 +166,9 @@ public class StandardMob {
if (mob.enemy != null && mob.enemy.size() > 0 && !mob.enemy.contains(loadedPlayer.getRace().getRaceType().getMonsterType())) if (mob.enemy != null && mob.enemy.size() > 0 && !mob.enemy.contains(loadedPlayer.getRace().getRaceType().getMonsterType()))
continue; continue;
if(mostHated == null)
mostHated = loadedPlayer;
if(mob.hate_values.containsKey(loadedPlayer)) if(mob.hate_values.containsKey(loadedPlayer))
if(mob.hate_values.get(loadedPlayer) > mob.hate_values.get(mostHated)) if(mob.hate_values.get(loadedPlayer) > mob.hate_values.get(mostHated))
mostHated = loadedPlayer; mostHated = loadedPlayer;
@ -181,14 +182,16 @@ public class StandardMob {
if(mob.combatTarget != null){ if(mob.combatTarget != null){
//chase player //chase player
if(!CombatUtilities.inRange2D(mob,mob.combatTarget,mob.getRange())) if(!CombatUtilities.inRange2D(mob,mob.combatTarget,mob.getRange())) {
MovementUtilities.aiMove(mob, mob.combatTarget.loc, false); MovementUtilities.aiMove(mob, mob.combatTarget.loc, false);
}else{
mob.stopMovement(mob.getMovementLoc());
}
}else{ }else{
//patrol //patrol
if (mob.isMoving()) { if (mob.isMoving())
return; return;
}
Vector3fImmutable patrolPoint = Vector3fImmutable.getRandomPointOnCircle(mob.bindLoc, 40f); Vector3fImmutable patrolPoint = Vector3fImmutable.getRandomPointOnCircle(mob.bindLoc, 40f);
MovementUtilities.aiMove(mob, patrolPoint, true); MovementUtilities.aiMove(mob, patrolPoint, true);
} }
@ -227,7 +230,7 @@ public class StandardMob {
} }
} }
public static void MobCallForHelp(Mob mob){ public static void MobCallForHelp(Mob mob){
HashSet<AbstractWorldObject> mobs = WorldGrid.getObjectsInRangePartial(mob.loc,20f, MBServerStatics.MASK_MOB); HashSet<AbstractWorldObject> mobs = WorldGrid.getObjectsInRangePartial(mob.loc,60f, MBServerStatics.MASK_MOB);
for(AbstractWorldObject awo : mobs){ for(AbstractWorldObject awo : mobs){
Mob responder = (Mob)awo; Mob responder = (Mob)awo;
if(responder.combatTarget == null) if(responder.combatTarget == null)

Loading…
Cancel
Save