Guest User

TryCàC

a guest
Jun 9th, 2012
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.09 KB | None | 0 0
  1. public void tryCaC(Personnage perso, int cellID) {
  2. Fighter caster = getFighterByPerso(perso);
  3.  
  4. if (caster == null) {
  5. return;
  6. }
  7.  
  8. if (_ordreJeu.get(_curPlayer).getGUID() != caster.getGUID())//Si ce n'est pas a lui de jouer
  9. {
  10. return;
  11. }
  12.  
  13. if (perso.getObjetByPos(Constants.ITEM_POS_ARME) == null)//S'il n'a pas de CaC
  14. {
  15. if (_curFighterPA < 4)//S'il n'a pas assez de PA
  16. {
  17. return;
  18. }
  19.  
  20. SocketManager.GAME_SEND_GAS_PACKET_TO_FIGHT(this, 7, perso.get_GUID());
  21.  
  22. //Si le joueur est invisible
  23. if (caster.isHide()) {
  24. caster.unHide(-1);
  25. }
  26.  
  27. Fighter target = _map.getCase(cellID).getFirstFighter();
  28.  
  29. SocketManager.GAME_SEND_GA_PACKET_TO_FIGHT(this, 7, 303, perso.get_GUID() + "", cellID + "");
  30.  
  31. if (target != null) {
  32. int dmg = Formulas.getRandomJet("1d5+0");
  33. //et pour les item type feu eau agi ?
  34. int finalDommage = Formulas.calculFinalDommage(this, caster, target, Constants.ELEMENT_NEUTRE, dmg, false, true, -1);
  35. finalDommage = SpellEffect.applyOnHitBuffs(finalDommage, target, caster, this);//S'il y a des buffs sp�ciaux
  36.  
  37. if (finalDommage > target.getPDV()) {
  38. finalDommage = target.getPDV();//Target va mourrir
  39. }
  40. target.removePDV(finalDommage);
  41. finalDommage = -(finalDommage);
  42. SocketManager.GAME_SEND_GA_PACKET_TO_FIGHT(this, 7, 100, caster.getGUID() + "", target.getGUID() + "," + finalDommage);
  43. }
  44. _curFighterPA -= 4;
  45. SocketManager.GAME_SEND_GA_PACKET_TO_FIGHT(this, 7, 102, perso.get_GUID() + "", perso.get_GUID() + ",-4");
  46. SocketManager.GAME_SEND_GAF_PACKET_TO_FIGHT(this, 7, 0, perso.get_GUID());
  47.  
  48. if (target.getPDV() <= 0) {
  49. onFighterDie(target, target);
  50. }
  51. verifIfTeamAllDead();
  52. } else {
  53. Objet arme = perso.getObjetByPos(Constants.ITEM_POS_ARME);
  54.  
  55. //Pierre d'�mes = EC
  56. if (arme.getTemplate().getType() == 83) {
  57. SocketManager.GAME_SEND_GA_PACKET_TO_FIGHT(this, 7, 305, perso.get_GUID() + "", "");//Echec Critique Cac
  58. SocketManager.GAME_SEND_GAF_PACKET_TO_FIGHT(this, 7, 0, perso.get_GUID());//Fin de l'action
  59. try {
  60. Thread.sleep(500);
  61. } catch (Exception e) {
  62. }
  63. endTurn();
  64. }
  65.  
  66. int PACost = arme.getTemplate().getPACost();
  67.  
  68. if (_curFighterPA < PACost)//S'il n'a pas assez de PA
  69. {
  70.  
  71. return;
  72. }
  73. SocketManager.GAME_SEND_GAS_PACKET_TO_FIGHT(this, 7, perso.get_GUID());
  74.  
  75. boolean isEc = arme.getTemplate().getTauxEC() != 0 && Formulas.getRandomValue(1, arme.getTemplate().getTauxEC()) == arme.getTemplate().getTauxEC();
  76. if (isEc) {
  77. if (Ancestra.CONFIG_DEBUG) {
  78. GameServer.addToLog(perso.get_name() + " Echec critique sur le CaC ");
  79. }
  80. SocketManager.GAME_SEND_GA_PACKET_TO_FIGHT(this, 7, 305, perso.get_GUID() + "", "");//Echec Critique Cac
  81. SocketManager.GAME_SEND_GAF_PACKET_TO_FIGHT(this, 7, 0, perso.get_GUID());//Fin de l'action
  82. endTurn();
  83. } else {
  84. SocketManager.GAME_SEND_GA_PACKET_TO_FIGHT(this, 7, 303, perso.get_GUID() + "", cellID + "");
  85. boolean isCC = caster.testIfCC(arme.getTemplate().getTauxCC());
  86. if (isCC) {
  87. if (Ancestra.CONFIG_DEBUG) {
  88. GameServer.addToLog(perso.get_name() + " Coup critique sur le CaC");
  89. }
  90. SocketManager.GAME_SEND_GA_PACKET_TO_FIGHT(this, 7, 301, perso.get_GUID() + "", "0");
  91. }
  92.  
  93. //Si le joueur est invisible
  94. if (caster.isHide()) {
  95. caster.unHide(-1);
  96. }
  97.  
  98. ArrayList<SpellEffect> effets = arme.getEffects();
  99. if (isCC) {
  100. effets = arme.getCritEffects();
  101. }
  102. for (SpellEffect SE : effets) {
  103. if (_state != Constants.FIGHT_STATE_ACTIVE) {
  104. break;
  105. }
  106. ArrayList<Fighter> cibles = Pathfinding.getCiblesByZoneByWeapon(this, arme.getTemplate().getType(), _map.getCase(cellID), caster.get_fightCell().getID());
  107. SE.setTurn(0);
  108. SE.applyToFight(this, caster, cibles, true);
  109. }
  110. _curFighterPA -= PACost;
  111. SocketManager.GAME_SEND_GA_PACKET_TO_FIGHT(this, 7, 102, perso.get_GUID() + "", perso.get_GUID() + ",-" + PACost);
  112. SocketManager.GAME_SEND_GAF_PACKET_TO_FIGHT(this, 7, 0, perso.get_GUID());
  113. verifIfTeamAllDead();
  114. }
  115. }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment