Advertisement
IhavenonameSDA

No Upgrade Paras Fight

Jun 28th, 2018
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.14 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <stdlib.h>
  4. #include <cstring>
  5.  
  6. using namespace std;
  7.  
  8. struct move{
  9.     string name;
  10.     int id;
  11.     int effect;
  12.     int defense;
  13.     int wait;
  14.     int special;
  15. };
  16.  
  17. int attempts = 0; //total attempts: 1073741824
  18. int Phealth = 75;
  19. int Pwait = 0;
  20. int Bhealth = 140;
  21. int Bwait = 0;
  22. int bestHealth = 140;
  23. int Bmove = 1;
  24. string bestStrat = "";
  25. int battleIndex = 0;
  26. move strategy[10];
  27. move movelist[12]; //First 8 are yours, last 4 are boss.
  28.  
  29. void initializeMoves();
  30. void setMove(string a, int b, int c, int d, int e, int f);
  31. void resetBattle();
  32. void arrayToString();
  33. void bossAttack();
  34.  
  35.  
  36. int main(){
  37.     initializeMoves();
  38.    
  39.     while(attempts < 1073741824 && bestHealth > 0){
  40.         //define strategy array based on attempts
  41.         strategy[0] = movelist[attempts % 8];
  42.         strategy[1] = movelist[(attempts / 8) % 8];
  43.         strategy[2] = movelist[(attempts / 64) % 8];
  44.         strategy[3] = movelist[(attempts / 512) % 8];
  45.         strategy[4] = movelist[(attempts / 4096) % 8];
  46.         strategy[5] = movelist[(attempts / 32768) % 8];
  47.         strategy[6] = movelist[(attempts / 262144) % 8];
  48.         strategy[7] = movelist[(attempts / 2097152) % 8];
  49.         strategy[8] = movelist[(attempts / 16777216) % 8];
  50.         strategy[9] = movelist[(attempts / 134217728) % 8];
  51.            
  52.         battleIndex = 0;
  53.         resetBattle();
  54.         while(Phealth > 0 && Bhealth > 0 && Bhealth <= 140 && battleIndex < 10){
  55.             //fight loop goes here
  56.            
  57.             if(Pwait == 0){
  58.                 //player attack
  59.                 if(strategy[battleIndex].special==0){
  60.                     Bhealth -= (strategy[battleIndex].effect - movelist[(Bmove+7)].defense);
  61.                 }
  62.                 if(strategy[battleIndex].special==1){
  63.                     Phealth += strategy[battleIndex].effect;
  64.                 }
  65.                 if(strategy[battleIndex].special==2){
  66.                     Bhealth -= (strategy[battleIndex].effect);
  67.                 }
  68.                 battleIndex++;
  69.                 Pwait = strategy[battleIndex%10].wait;
  70.             }
  71.             if(Bwait == 0){
  72.                 bossAttack();
  73.             }
  74.            
  75.             Pwait--;
  76.             Bwait--;
  77.         }
  78.         if(Bhealth < 140){
  79.             if(Bhealth < bestHealth){
  80.                 bestHealth = Bhealth;
  81.                 arrayToString();
  82.                 cout << "New Best: " << bestStrat << endl;
  83.                 cout << bestHealth << endl;
  84.                 bestStrat = "";
  85.             }
  86.         }
  87. //      if(attempts % 5000000 == 0){
  88. //          cout << "Attempts: " << attempts << endl;  
  89. //      }
  90.        
  91.         attempts++;
  92.     }
  93.    
  94.     cout << "Best fight: " << bestStrat << endl;
  95.     cout << bestHealth << endl;
  96. }
  97.  
  98.  
  99. void initializeMoves(){
  100.     setMove("Longbow", 1, 11, 4, 5, 0);
  101.     setMove("Crossbow", 2, 16, 2, 6, 0);
  102.     setMove("Wing Guard", 3, 0, 18, 6, 0);
  103.     setMove("Wooden Shield", 4, 0, 20, 8, 0);
  104.     setMove("Mythril Sword", 5, 20, 13, 8, 0);
  105.     setMove("Broadsword", 6, 23, 18, 14, 0);
  106.     setMove("Heal", 7, 25, 2, 15, 1);
  107.     setMove("Thunder", 8, 35, 2, 20, 2);
  108.    
  109.     setMove("Shock+1", 9, 20, 4, 10, 0);
  110.     setMove("Shock+2", 10, 22, 6, 5, 0);
  111.     setMove("Shock+3", 11, 24, 8, 5, 0);
  112.     setMove("Drain", 12, 35, 0, 17, 3);
  113. }
  114.  
  115. //a is the attack name. b is the id of the move. c, d and e are effect, defense and wait.
  116. //f is any special properties: 0 = none, 1 = Heal, 2 = Piercing, 3 = both.
  117. //Stun is unimplemented and instead shortcutted by shortening the wait of the next move, given the fixed attack pattern.
  118. void setMove(string a, int b, int c, int d, int e, int f){
  119.     movelist[b-1].name = a;
  120.     movelist[b-1].id = b;
  121.     movelist[b-1].effect = c;
  122.     movelist[b-1].defense = d;
  123.     movelist[b-1].wait = e;
  124.     movelist[b-1].special = f;
  125. }
  126.  
  127. void resetBattle(){
  128.     Phealth = 75;
  129.     Pwait = strategy[battleIndex].wait;
  130.     Bhealth = 140;
  131.     Bwait = 10;
  132.     Bmove = 1;
  133. }
  134.  
  135. void arrayToString(){
  136.     for(int i=0;i<10;i++){
  137.         bestStrat.append(strategy[i].name);
  138.         bestStrat.append(" | ");
  139.     }
  140. }
  141.  
  142. void bossAttack(){
  143.     if(movelist[(Bmove+7)].special == 0){
  144.         Phealth -= (movelist[(Bmove+7)].effect - strategy[battleIndex].defense);
  145.     }
  146.     if(movelist[(Bmove+7)].special == 3){
  147.         Phealth -= (movelist[(Bmove+7)].effect);
  148.         Bhealth += (movelist[(Bmove+7)].effect);
  149.     }
  150.     Bmove++;
  151.     if(Bmove == 5){
  152.         Bmove = 1; 
  153.     }
  154.     Bwait = movelist[(Bmove+7)].wait;
  155. }
  156.  
  157.  
  158. OUTPUT BELOW
  159.  
  160. New Best: Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow |
  161. 120
  162.  
  163. New Best: Crossbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow |
  164. 111
  165.  
  166. New Best: Thunder | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow |
  167. 107
  168.  
  169. New Best: Crossbow | Crossbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow |
  170. 106
  171.  
  172. New Best: Thunder | Crossbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow |
  173. 102
  174.  
  175. New Best: Mythril Sword | Mythril Sword | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow |
  176. 89
  177.  
  178. New Best: Broadsword | Mythril Sword | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow |
  179. 86
  180.  
  181. New Best: Mythril Sword | Broadsword | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow |
  182. 84
  183.  
  184. New Best: Mythril Sword | Crossbow | Mythril Sword | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow |
  185. 82
  186.  
  187. New Best: Mythril Sword | Broadsword | Mythril Sword | Crossbow | Longbow | Longbow | Longbow | Longbow | Longbow | Longbow |
  188. 81
  189.  
  190. New Best: Mythril Sword | Broadsword | Crossbow | Crossbow | Crossbow | Longbow | Longbow | Longbow | Longbow | Longbow |
  191. 80
  192.  
  193. New Best: Broadsword | Mythril Sword | Mythril Sword | Crossbow | Crossbow | Longbow | Longbow | Longbow | Longbow | Longbow |
  194. 78
  195.  
  196. New Best: Mythril Sword | Broadsword | Mythril Sword | Crossbow | Crossbow | Longbow | Longbow | Longbow | Longbow | Longbow |
  197. 76
  198.  
  199. New Best: Mythril Sword | Broadsword | Thunder | Mythril Sword | Mythril Sword | Longbow | Longbow | Longbow | Longbow | Longbow |
  200. 69
  201.  
  202. New Best: Mythril Sword | Broadsword | Thunder | Mythril Sword | Mythril Sword | Crossbow | Longbow | Longbow | Longbow | Longbow |
  203. 64
  204.  
  205. New Best: Broadsword | Broadsword | Mythril Sword | Crossbow | Longbow | Wing Guard | Longbow | Longbow | Longbow | Longbow |
  206. 60
  207.  
  208. New Best: Mythril Sword | Broadsword | Broadsword | Crossbow | Longbow | Wing Guard | Longbow | Longbow | Longbow | Longbow |
  209. 58
  210.  
  211. New Best: Mythril Sword | Broadsword | Crossbow | Longbow | Broadsword | Wing Guard | Longbow | Longbow | Longbow | Longbow |
  212. 54
  213.  
  214. New Best: Crossbow | Mythril Sword | Mythril Sword | Mythril Sword | Heal | Mythril Sword | Longbow | Longbow | Longbow | Longbow |
  215. 53
  216.  
  217. New Best: Mythril Sword | Broadsword | Crossbow | Crossbow | Longbow | Broadsword | Longbow | Longbow | Longbow | Longbow |
  218. 38
  219.  
  220. New Best: Mythril Sword | Broadsword | Mythril Sword | Crossbow | Mythril Sword | Mythril Sword | Wing Guard | Longbow | Longbow | Longbow |
  221. 37
  222.  
  223. New Best: Mythril Sword | Broadsword | Mythril Sword | Crossbow | Crossbow | Mythril Sword | Mythril Sword | Longbow | Longbow | Longbow |
  224. 21
  225.  
  226. New Best: Crossbow | Mythril Sword | Mythril Sword | Crossbow | Crossbow | Crossbow | Crossbow | Broadsword | Mythril Sword | Longbow |
  227. 19
  228.  
  229. New Best: Crossbow | Mythril Sword | Mythril Sword | Crossbow | Crossbow | Crossbow | Crossbow | Broadsword | Crossbow | Crossbow |
  230. 18
  231.  
  232. Best fight:
  233. 18
  234.  
  235. --------------------------------
  236. Process exited after 767.5 seconds with return value 0
  237. Press any key to continue . . .
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement