public void calculateDangerLevel(){
  int maxLevel=1;
  int levelSum=1;
  for (  CreatureRespawnPoint spawner : respawnPoints) {
    Creature creature=spawner.getPrototypeCreature();
    if (creature.isRare()) {
      continue;
    }
    int level=creature.getLevel() + 1;
    if (level > 1000) {
      continue;
    }
    maxLevel=Math.max(level,maxLevel);
    levelSum+=level;
  }
  int area=getFreeArea() + 1;
  double dangerLevel=maxLevel * (1 + DANGER_WEIGHT_CREATURE_DENSITY * (levelSum - maxLevel) / maxLevel / Math.sqrt(area)) - 1;
  if (maxLevel > 0) {
    if (attributes == null) {
      attributes=new ZoneAttributes(this);
    }
    attributes.put("danger_level",Double.toString(dangerLevel));
  }
}

public void calculateDangerLevel ( ) { int maxLevel = 1 ; int levelSum = 1 ; for ( CreatureRespawnPoint spawner : respawnPoints ) { Creature creature = spawner . getPrototypeCreature ( ) ; if ( creature . isRare ( ) ) { continue ; } int level = creature . getLevel ( ) + 1 ; if ( level > 1000 ) { continue ; } maxLevel = Math . max ( level , maxLevel ) ; levelSum += level ; } int area = getFreeArea ( ) + 1 ; double dangerLevel = maxLevel * ( 1 + DANGER_WEIGHT_CREATURE_DENSITY * ( levelSum - maxLevel ) / maxLevel / Math . sqrt ( area ) ) - 1 ; if ( maxLevel > 0 ) { if ( attributes == null ) { attributes = new ZoneAttributes ( this ) ; } attributes . put ( "danger_level" , Double . toString ( dangerLevel ) ) ; } }
calculate danger level for the zone , and store it in the data layer .
