int tc=Rand.randGaussian(0,RAT_TYPES.size());
if ((tc>(RAT_TYPES.size()-1)) || (tc<0)) {
tc=0;
}
// checking if EntityManager knows about this creature type.
final Creature tempCreature = new Creature((Creature) manager.getEntity(RAT_TYPES.get(tc)));
final Creature rat = new Creature(tempCreature.getNewInstance());
// chosen place is occupied
if (zone.collides(rat,x,y)) {
// Could not place the creature here.
// Treat it like it was never exists.
logger.debug("RATS " + zone.getName() + " " + x + " " + y + " collided.");
continue;
} else if (zone.getName().startsWith("0")) {
// If we can't make it here, we can't make it anywhere ...
// just checking the 0 level zones atm
// the rat is not in the zone yet so we can't call the smaller version of the searchPath method
final List<Node> path = Path.searchPath(zone, x, y, zone.getWidth()/2,
zone.getHeight()/2, (64+64)*2);
if (path == null || path.size() == 0){
logger.debug("RATS " + zone.getName() + " " + x + " " + y + " no path to " + zone.getWidth()/2 + " " + zone.getHeight()/2);
continue;
}
}
// spawn creature
rat.registerObjectsForNotification(ratsObserver);
/* -- commented because of these noises reflects on all archrats in game -- */
// add unique noises to humanoids
if (tc==RAT_TYPES.indexOf("archrat")) {
final LinkedList<String> ll = new LinkedList<String>(
Arrays.asList("We will capture Ados!",
"Our revenge will awesome!"));
LinkedHashMap<String, LinkedList<String>> lhm =
new LinkedHashMap<String, LinkedList<String>>();
// add to all states except death.
lhm.put("idle", ll);
lhm.put("fight", ll);
lhm.put("follow", ll);
rat.setNoises(lhm);
}
StendhalRPAction.placeat(zone, rat, x, y);
rats.add(rat);
}