deez

Ancestrar.Percepteur_all

Jun 27th, 2012
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.63 KB | None | 0 0
  1. // IA du percepteur
  2. // IA => apply_typePerco()
  3. // Remplacer par :
  4.  
  5.                 private static void apply_typePerco(Fighter F, Fight fight)
  6.                 {
  7.                 int notWhile = 0;
  8.                  try
  9.                  {
  10.                    do
  11.                    {
  12.                            notWhile++;
  13.                      if (notWhile >= 12) stop = true;
  14.                      if (notWhile > 15) return;
  15.                                 Fighter T = getNearestEnnemy(fight, F);
  16.                                 if(T == null) return;
  17.                                 int attack = attackIfPossiblePerco(fight,F);
  18.                                 if(attack != 0)//Attaque
  19.                                 {
  20.                                         if(attack == 5) stop = true;//EC
  21.                                         if(!moveFarIfPossible(fight, F))//fuite
  22.                                         {
  23.                                                         if(!HealIfPossiblePerco(fight,F,false))//soin allié
  24.                                                         {
  25.                                                                 if(!buffIfPossiblePerco(fight,F,T))//buff allié
  26.                                                                 {
  27.                                                                         if(!HealIfPossiblePerco(fight,F,true))//auto-soin
  28.                                                                         {
  29.                                                                                 if(!buffIfPossiblePerco(fight,F,F))//auto-buff
  30.                                                                                 {
  31.                                                                                                 stop = true;
  32.                                                                                 }
  33.                                                                         }
  34.                                                                 }
  35.                                                         }
  36.                                         }
  37.                                 }
  38.                                 if(stop) break;
  39.                    }while(F.canPlay());
  40.                  }catch(Exception e)
  41.                  {
  42.                          return;
  43.                  }
  44.                 }
  45.  
  46. // Faire droper le percepteur,et droper le joueur
  47. // Percepteur => Percepteur(),Fight => getGE()
  48. // Remplacer par :
  49.  
  50. //Percepteur Importe les array:
  51.     public ArrayList<Drop> getDrops() {
  52.         ArrayList<Drop> toReturn = new ArrayList<World.Drop>();
  53.         for(Objet obj : _objets.values()) {
  54.             toReturn.add(new Drop(obj.getTemplate().getID(),0, 100, obj.getQuantity()));
  55.         }
  56.         return toReturn;
  57.     }
  58.  
  59. //Fight après le for de //Calcul des drops possibles
  60.             if(_type == Constants.FIGHT_TYPE_PVT)
  61.             {
  62.                 minkamas = (int)_perco.getKamas() / TEAM1.size();
  63.                 maxkamas = minkamas;
  64.                 possibleDrops.addAll(_perco.getDrops());    
  65.             }
  66.  
  67. // Attaque du perco
  68. // IA => attackIfPossiblePerco()
  69. // Tous remplacer
  70.  
  71.         private static int attackIfPossiblePerco(Fight fight, Fight.Fighter fighter)
  72.         {
  73.             Map<Integer,Fighter> ennemyList = getLowHpEnnemyList(fight,fighter);
  74.             SortStats SS = null;
  75.             Fighter target = null;
  76.            
  77.             for(Entry<Integer, Fighter> t : ennemyList.entrySet())
  78.             {
  79.                 SS = getBestSpellForTargetPerco(fight, fighter, (Fight.Fighter)t.getValue());
  80.                 if (SS == null)
  81.                     continue;
  82.                 target = (Fight.Fighter)t.getValue();
  83.                 break;
  84.             }
  85.            
  86.             int curTarget = 0; int cell = 0;
  87.             Sort.SortStats SS2 = null;
  88.            
  89.             for (Entry<Integer, SortStats> S : World.getGuild(fighter.getPerco().GetPercoGuildID()).getSpells().entrySet())
  90.             {
  91.                 if (S.getValue() != null) {
  92.                     int targetVal = getBestTargetZone(fight, fighter, (Sort.SortStats)S.getValue(), fighter.get_fightCell().getID());
  93.                     if ((targetVal == -1) || (targetVal == 0))
  94.                         continue;
  95.                     int nbTarget = targetVal / 1000;
  96.                     int cellID = targetVal - nbTarget * 1000;
  97.                     if (nbTarget <= curTarget)
  98.                         continue;
  99.                     curTarget = nbTarget;
  100.                     cell = cellID;
  101.                     SS2 = (Sort.SortStats)S.getValue();
  102.                 }
  103.             }
  104.            
  105.             if ((curTarget > 0) && (cell > 0) && (cell < 480) && (SS2 != null))
  106.             {
  107.                 int attack = fight.tryCastSpell(fighter, SS2, cell);
  108.                 if (attack != 0)
  109.                     return attack;
  110.             }
  111.             else
  112.             {
  113.                 if ((target == null) || (SS == null))
  114.                     return 666;
  115.                 int attack = fight.tryCastSpell(fighter, SS, target.get_fightCell().getID());
  116.                 if (attack != 0)
  117.                     return attack;
  118.             }
  119.             return 0;
  120.         }
  121.  
  122.  
  123. // Hmm je croit que c'est bon ;)
  124. // Tous à été tester
Advertisement
Add Comment
Please, Sign In to add comment