falyptus

Formule d'XP de desperion traduite en JAVA

Jul 11th, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.39 KB | None | 0 0
  1. /**
  2.  *
  3.  * @author Desperion emulator 2.0 by Little-Scaraby and Nekkro
  4.  *
  5.  */
  6. public static int truncate(double n)
  7. {
  8.     double loc2 = Math.pow(Double.valueOf(10), Double.valueOf(0));
  9.     double loc3 = n * loc2;
  10.     return (int)((int)(loc3) / loc2);
  11. }
  12.  
  13. /**
  14.  *
  15.  * @author Desperion emulator 2.0 by Little-Scaraby and Nekkro
  16.  *
  17.  */
  18. public static long calculateXpMonster(double groupXp, double groupLevel, double highestMonsterLevel, double ageBonus, Fighter ch, ArrayList<Fighter> team, double mountRatio, double guildRatio)
  19. {
  20.     // Calcul du niveau de la team, ainsi que du niveau du personnage le plus fort
  21.     double totalTeamLevel = 0;
  22.     double highestTeamLevel = 0;
  23.     for(int a = 0; a < team.size(); ++a)
  24.     {
  25.         totalTeamLevel += team.get(a).getLvl();
  26.         if(team.get(a).getLvl() > highestTeamLevel)
  27.             highestTeamLevel = team.get(a).getLvl();
  28.     }
  29.        
  30.     // Calcul du coefficient dû au niveau de la team par rapport au niveau du groupe de monstres
  31.     double levelCoeff = 1;
  32.     if(totalTeamLevel - 5 > groupLevel)
  33.         levelCoeff = groupLevel / totalTeamLevel;
  34.     else if(totalTeamLevel + 10 < groupLevel)
  35.         levelCoeff = (totalTeamLevel + 10) / groupLevel;
  36.        
  37.     // pondération avec le niveau de ch
  38.     double min = Math.min(ch.getLvl(), truncate(2.5 * highestMonsterLevel));
  39.     double loc16 = min / totalTeamLevel * 100;
  40.  
  41.     /*
  42.         détermination d'un facteur de multiplication en fonction du nombre de personnes
  43.         dans la team: chaque personnage de la team doit avoir un niveau supérieur à
  44.         (highestTeamLevel / 3) pour être considéré
  45.     */
  46.     double[] teamFactors = {1, 1.1, 1.5, 2.3, 3.1, 3.6, 4.2, 4.7};
  47.     byte index = 0;
  48.     for(int a = 0; a < team.size(); ++a)
  49.     {
  50.         if(team.get(a).getLvl() >= highestTeamLevel / 3)
  51.             ++index;
  52.     }
  53.     if(index == 0)
  54.         index = 1;
  55.        
  56.     double loc20 = truncate(groupXp * teamFactors[index - 1] * levelCoeff);
  57.     double loc22 = truncate(loc16 / 100 * loc20);
  58.  
  59.     double totalWisdom = ch.getTotalStats().getEffect(Constants.STATS_ADD_SAGE);
  60.     if(totalWisdom < 0)
  61.         totalWisdom = 0;
  62.  
  63.     double ageCoeff = ageBonus <= 0 ? 1 : (1 + ageBonus / 100);
  64.     double xp = truncate(truncate(loc22 * (100 + totalWisdom) / 100) * ageCoeff); // xp totale gagnée par ch
  65.  
  66.     // on retranche l'xp perdue à cause de la drago
  67.     if(mountRatio > 0)
  68.         xp -= truncate(xp * mountRatio / 100);
  69.     if(guildRatio > 0) // idem (la guilde passe après la drago)
  70.         xp -= truncate(xp * guildRatio / 100);
  71.        
  72.     return (long) xp;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment