| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -24,7 +24,7 @@ public class MonsterAi extends EntityModule implements EntityMoveListener { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						private boolean sleeping = true; | 
					 | 
					 | 
					 | 
						private boolean sleeping = true; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						private boolean chasing = false; | 
					 | 
					 | 
					 | 
						private boolean chasing = false; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						private AiTimer timerFindPrey = new AiTimer(3) { | 
					 | 
					 | 
					 | 
						private final AiTimer timerFindPrey = new AiTimer(3) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							@Override | 
					 | 
					 | 
					 | 
							@Override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							public void run() | 
					 | 
					 | 
					 | 
							public void run() | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -34,7 +34,7 @@ public class MonsterAi extends EntityModule implements EntityMoveListener { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							} | 
					 | 
					 | 
					 | 
							} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						}; | 
					 | 
					 | 
					 | 
						}; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						private AiTimer timerSleepStart = new AiTimer(10) { | 
					 | 
					 | 
					 | 
						private final AiTimer timerSleepStart = new AiTimer(10) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							@Override | 
					 | 
					 | 
					 | 
							@Override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							public void run() | 
					 | 
					 | 
					 | 
							public void run() | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -49,7 +49,8 @@ public class MonsterAi extends EntityModule implements EntityMoveListener { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						private int targetId = -1; | 
					 | 
					 | 
					 | 
						private int targetId = -1; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						public MonsterAi(final Entity entity) { | 
					 | 
					 | 
					 | 
						public MonsterAi(final Entity entity) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							super(entity); | 
					 | 
					 | 
					 | 
							super(entity); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							pathfcNoDoor = new PathFindingContextProxy(entity.getPathfindingContext()) { | 
					 | 
					 | 
					 | 
							pathfcNoDoor = new PathFindingContextProxy(entity.getPathfindingContext()) { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -57,7 +58,7 @@ public class MonsterAi extends EntityModule implements EntityMoveListener { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								@Override | 
					 | 
					 | 
					 | 
								@Override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								public boolean isAccessible(Coord pos) | 
					 | 
					 | 
					 | 
								public boolean isAccessible(Coord pos) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								{ | 
					 | 
					 | 
					 | 
								{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									Tile t = entity.getLevel().getTile(pos); | 
					 | 
					 | 
					 | 
									final Tile t = entity.getLevel().getTile(pos); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									if (t.isDoor()) return false; | 
					 | 
					 | 
					 | 
									if (t.isDoor()) return false; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									 | 
					 | 
					 | 
					 | 
									 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									return super.isAccessible(pos); | 
					 | 
					 | 
					 | 
									return super.isAccessible(pos); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -71,14 +72,13 @@ public class MonsterAi extends EntityModule implements EntityMoveListener { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						{ | 
					 | 
					 | 
					 | 
						{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							if (rand.nextInt(3) == 0) return; // not hungry right now
 | 
					 | 
					 | 
					 | 
							if (rand.nextInt(3) == 0) return; // not hungry right now
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							Entity prey = entity.getLevel().getClosestEntity(entity, EntityType.PLAYER, getScanRadius()); | 
					 | 
					 | 
					 | 
							final Entity prey = entity.getLevel().getClosestEntity(entity, EntityType.PLAYER, getScanRadius()); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							if (prey != null) { | 
					 | 
					 | 
					 | 
							if (prey != null) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								 | 
					 | 
					 | 
					 | 
								 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								// check if reachable without leaving room
 | 
					 | 
					 | 
					 | 
								// check if reachable without leaving room
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								List<Coord> noDoorPath = PathFinder.findPath(pathfcNoDoor, entity.getCoord(), prey.getCoord()); | 
					 | 
					 | 
					 | 
								final List<Coord> noDoorPath = PathFinder.findPath(pathfcNoDoor, entity.getCoord(), prey.getCoord()); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								 | 
					 | 
					 | 
					 | 
								 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								if (noDoorPath == null) { | 
					 | 
					 | 
					 | 
								if (noDoorPath == null) { return; // cant reach, give up
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									return; // cant reach, give up
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								} | 
					 | 
					 | 
					 | 
								} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								 | 
					 | 
					 | 
					 | 
								 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								startChasing(prey); | 
					 | 
					 | 
					 | 
								startChasing(prey); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -136,7 +136,7 @@ public class MonsterAi extends EntityModule implements EntityMoveListener { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						public void onStepFinished() | 
					 | 
					 | 
					 | 
						public void onStepFinished() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						{ | 
					 | 
					 | 
					 | 
						{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							if (chasing) { | 
					 | 
					 | 
					 | 
							if (chasing) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								Entity prey = entity.getLevel().getEntity(targetId); | 
					 | 
					 | 
					 | 
								final Entity prey = entity.getLevel().getEntity(targetId); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								if (prey == null || prey.isDead()) { | 
					 | 
					 | 
					 | 
								if (prey == null || prey.isDead()) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									stopChasing(); | 
					 | 
					 | 
					 | 
									stopChasing(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									return; | 
					 | 
					 | 
					 | 
									return; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -153,13 +153,13 @@ public class MonsterAi extends EntityModule implements EntityMoveListener { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						private void stepTowardsPrey(Entity prey) | 
					 | 
					 | 
					 | 
						private void stepTowardsPrey(Entity prey) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						{ | 
					 | 
					 | 
					 | 
						{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							// if close enough
 | 
					 | 
					 | 
					 | 
							// if close enough
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							Coord preyPos = prey.getCoord(); | 
					 | 
					 | 
					 | 
							final Coord preyPos = prey.getCoord(); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							if (preyPos.dist(entity.getCoord()) <= 1.5) { | 
					 | 
					 | 
					 | 
							if (preyPos.dist(entity.getCoord()) <= 1.5) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								attackPrey(prey); | 
					 | 
					 | 
					 | 
								attackPrey(prey); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								return; | 
					 | 
					 | 
					 | 
								return; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							} | 
					 | 
					 | 
					 | 
							} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							List<Step> preyPath = getPathToPrey(prey); | 
					 | 
					 | 
					 | 
							final List<Step> preyPath = getPathToPrey(prey); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							if (preyPath.size() > getPreyAbandonDistance()) { | 
					 | 
					 | 
					 | 
							if (preyPath.size() > getPreyAbandonDistance()) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								stopChasing(); | 
					 | 
					 | 
					 | 
								stopChasing(); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -176,7 +176,8 @@ public class MonsterAi extends EntityModule implements EntityMoveListener { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						} | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						protected int getAttackStrength() { | 
					 | 
					 | 
					 | 
						protected int getAttackStrength() | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							return 1; // For override
 | 
					 | 
					 | 
					 | 
							return 1; // For override
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						} | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |