Example #1
0
 public MobGroup(int Aid, int cID, String groupData) {
   int maxLevel = 0;
   id = Aid;
   align = Constants.ALIGNEMENT_NEUTRE;
   cellID = cID;
   aggroDistance = Constants.getAggroByLevel(maxLevel);
   isFix = true;
   _creationDate = System.currentTimeMillis();
   int guid = -1;
   for (String data : groupData.split(";")) {
     String[] infos = data.split(",");
     try {
       int id = Integer.parseInt(infos[0]);
       int min = Integer.parseInt(infos[1]);
       int max = Integer.parseInt(infos[2]);
       Monstre m = World.getMonstre(id);
       List<MobGrade> mgs = new ArrayList<MobGrade>();
       // on ajoute a la liste les grades possibles
       for (MobGrade MG : m.getGrades().values())
         if (MG.level >= min && MG.level <= max) mgs.add(MG);
       if (mgs.isEmpty()) continue;
       // On prend un grade au hasard entre 0 et size -1 parmis les mobs possibles
       _Mobs.put(guid, mgs.get(Formulas.getRandomValue(0, mgs.size() - 1)));
       guid--;
     } catch (Exception e) {
       continue;
     }
     ;
   }
   orientation = (Formulas.getRandomValue(0, 3) * 2) + 1;
 }
Example #2
0
    public MobGroup(
        int Aid, int Aalign, ArrayList<MobGrade> possibles, Carte Map, int cell, int maxSize) {
      id = Aid;
      align = Aalign;
      // Détermination du nombre de mob du groupe
      _creationDate = System.currentTimeMillis();

      int rand = 0;
      int nbr = 0;

      switch (maxSize) {
        case 0:
          return;
        case 1:
          nbr = 1;
          break;
        case 2:
          nbr = Formulas.getRandomValue(1, 2); // 1:50%	2:50%
          break;
        case 3:
          nbr = Formulas.getRandomValue(1, 3); // 1:33.3334%	2:33.3334%	3:33.3334%
          break;
        case 4:
          rand = Formulas.getRandomValue(0, 99);
          if (rand < 22) // 1:22%
          nbr = 1;
          else if (rand < 48) // 2:26%
          nbr = 2;
          else if (rand < 74) // 3:26%
          nbr = 3;
          else // 4:26%
          nbr = 4;
          break;
        case 5:
          rand = Formulas.getRandomValue(0, 99);
          if (rand < 15) // 1:15%
          nbr = 1;
          else if (rand < 35) // 2:20%
          nbr = 2;
          else if (rand < 60) // 3:25%
          nbr = 3;
          else if (rand < 85) // 4:25%
          nbr = 4;
          else // 5:15%
          nbr = 5;
          break;
        case 6:
          rand = Formulas.getRandomValue(0, 99);
          if (rand < 10) // 1:10%
          nbr = 1;
          else if (rand < 25) // 2:15%
          nbr = 2;
          else if (rand < 45) // 3:20%
          nbr = 3;
          else if (rand < 65) // 4:20%
          nbr = 4;
          else if (rand < 85) // 5:20%
          nbr = 5;
          else // 6:15%
          nbr = 6;
          break;
        case 7:
          rand = Formulas.getRandomValue(0, 99);
          if (rand < 9) // 1:9%
          nbr = 1;
          else if (rand < 20) // 2:11%
          nbr = 2;
          else if (rand < 35) // 3:15%
          nbr = 3;
          else if (rand < 55) // 4:20%
          nbr = 4;
          else if (rand < 75) // 5:20%
          nbr = 5;
          else if (rand < 91) // 6:16%
          nbr = 6;
          else // 7:9%
          nbr = 7;
          break;
        default:
          rand = Formulas.getRandomValue(0, 99);
          if (rand < 9) // 1:9%
          nbr = 1;
          else if (rand < 20) // 2:11%
          nbr = 2;
          else if (rand < 33) // 3:13%
          nbr = 3;
          else if (rand < 50) // 4:17%
          nbr = 4;
          else if (rand < 67) // 5:17%
          nbr = 5;
          else if (rand < 80) // 6:13%
          nbr = 6;
          else if (rand < 91) // 7:11%
          nbr = 7;
          else // 8:9%
          nbr = 8;
          break;
      }
      // On vérifie qu'il existe des monstres de l'alignement demandé pour éviter les boucles
      // infinies
      boolean haveSameAlign = false;
      for (MobGrade mob : possibles) {
        if (mob.getTemplate().getAlign() == align) haveSameAlign = true;
      }

      if (!haveSameAlign) return; // S'il n'y en a pas
      int guid = -1;

      int maxLevel = 0;
      for (int a = 0; a < nbr; a++) {
        MobGrade Mob = null;
        do {
          int random =
              Formulas.getRandomValue(
                  0, possibles.size() - 1); // on prend un mob au hasard dans le tableau
          Mob = possibles.get(random).getCopy();
        } while (Mob.getTemplate().getAlign() != align);

        if (Mob.getLevel() > maxLevel) maxLevel = Mob.getLevel();

        _Mobs.put(guid, Mob);
        guid--;
      }
      aggroDistance = Constants.getAggroByLevel(maxLevel);

      if (align != Constants.ALIGNEMENT_NEUTRE) aggroDistance = 15;

      cellID = (cell == -1 ? Map.getRandomFreeCellID() : cell);
      if (cellID == 0) return;

      orientation = Formulas.getRandomValue(0, 3) * 2;
      isFix = false;
    }
Example #3
0
 private long get_timeElapsedInSeconds() {
   return ((System.currentTimeMillis() - _creationDate)) / 1000;
 }