fork download
  1. /*
  2.  * Dire_Storm
  3.  * Gunner DPS Calculator
  4.  * 11 July 2016
  5.  */
  6.  
  7. #include <iostream>
  8. #include <iomanip>
  9. #include <string>
  10.  
  11. const int weapons = 33;
  12.  
  13. struct Gun{ // Gunner's weapon
  14. std::string name; // Name of gun
  15. int AT_min; // Minimum ATtack damage
  16. int AT_max; // Maximum ATtack damage
  17. int AGI_min; // Fastest rate of fire (minimum number of frames between shots)
  18. int AGI_max; // Slowest rate of fire (maximum number of frames between shots)
  19. int PC; // Projectile count
  20. };
  21.  
  22. struct Character{ // Gunner character
  23. int STR; // STRength stat in Gunner
  24. int DEX; // DEXterity stat in Gunner
  25. };
  26.  
  27. // Sets values to each Gun (Gun catalogue)
  28. void setGuns(Gun Guns[]){
  29. Guns[0].name = "Gun";
  30. Guns[0].AT_min = 2;
  31. Guns[0].AT_max = 6;
  32. Guns[0].AGI_min = 20;
  33. Guns[0].AGI_max = 30;
  34. Guns[0].PC = 1;
  35.  
  36. Guns[1].name = "Handgun";
  37. Guns[1].AT_min = 8;
  38. Guns[1].AT_max = 12;
  39. Guns[1].AGI_min = 20;
  40. Guns[1].AGI_max = 30;
  41. Guns[1].PC = 1;
  42.  
  43. Guns[2].name = "Submachine-gun";
  44. Guns[2].AT_min = 4;
  45. Guns[2].AT_max = 8;
  46. Guns[2].AGI_min = 5;
  47. Guns[2].AGI_max = 10;
  48. Guns[2].PC = 1;
  49.  
  50. Guns[3].name = "Shotgun";
  51. Guns[3].AT_min = 1;
  52. Guns[3].AT_max = 20;
  53. Guns[3].AGI_min = 50;
  54. Guns[3].AGI_max = 60;
  55. Guns[3].PC = 5;
  56.  
  57. Guns[4].name = "Rifle";
  58. Guns[4].AT_min = 20;
  59. Guns[4].AT_max = 40;
  60. Guns[4].AGI_min = 50;
  61. Guns[4].AGI_max = 60;
  62. Guns[4].PC = 1;
  63.  
  64. /*Guns[5].name = "Grenade";
  65.   Guns[5].AT_min = 8;
  66.   Guns[5].AT_max = 12;
  67.   Guns[5].AGI_min = 70;
  68.   Guns[5].AGI_max = 80;
  69.   Guns[5].PC = 1;*/
  70.  
  71. /*Guns[6].name = "Laser Gun";
  72.   Guns[6].AT_min = 8;
  73.   Guns[6].AT_max = 12;
  74.   Guns[6].AGI_min = 20;
  75.   Guns[6].AGI_max = 30;
  76.   Guns[6].PC = 1;*/
  77.  
  78. /*Guns[7].name = "Bazooka";
  79.   Guns[7].AT_min = 40;
  80.   Guns[7].AT_max = 60;
  81.   Guns[7].AGI_min = 80;
  82.   Guns[7].AGI_max = 90;
  83.   Guns[7].PC = 1;*/
  84.  
  85. Guns[8].name = "Homing Laser";
  86. Guns[8].AT_min = 8;
  87. Guns[8].AT_max = 12;
  88. Guns[8].AGI_min = 20;
  89. Guns[8].AGI_max = 30;
  90. Guns[8].PC = 2;
  91.  
  92. Guns[9].name = "Beretta";
  93. Guns[9].AT_min = 24;
  94. Guns[9].AT_max = 36;
  95. Guns[9].AGI_min = 20;
  96. Guns[9].AGI_max = 30;
  97. Guns[9].PC = 1;
  98.  
  99. Guns[10].name = "Uzi";
  100. Guns[10].AT_min = 12;
  101. Guns[10].AT_max = 24;
  102. Guns[10].AGI_min = 5;
  103. Guns[10].AGI_max = 10;
  104. Guns[10].PC = 1;
  105.  
  106. Guns[11].name = "Remington";
  107. Guns[11].AT_min = 1;
  108. Guns[11].AT_max = 40;
  109. Guns[11].AGI_min = 50;
  110. Guns[11].AGI_max = 60;
  111. Guns[11].PC = 7;
  112.  
  113. Guns[12].name = "Sniper Rifle";
  114. Guns[12].AT_min = 60;
  115. Guns[12].AT_max = 80;
  116. Guns[12].AGI_min = 50;
  117. Guns[12].AGI_max = 60;
  118. Guns[12].PC = 1;
  119.  
  120. /*Guns[13].name = "Grenade Launcher";
  121.   Guns[13].AT_min = 12;
  122.   Guns[13].AT_max = 24;
  123.   Guns[13].AGI_min = 70;
  124.   Guns[13].AGI_max = 80;
  125.   Guns[13].PC = 1;*/
  126.  
  127. /*Guns[14].name = "Laser Beam Gun";
  128.   Guns[14].AT_min = 16;
  129.   Guns[14].AT_max = 24;
  130.   Guns[14].AGI_min = 20;
  131.   Guns[14].AGI_max = 30;
  132.   Guns[14].PC = 1;*/
  133.  
  134. /*Guns[15].name = "Cannon";
  135.   Guns[15].AT_min = 80;
  136.   Guns[15].AT_max = 120;
  137.   Guns[15].AGI_min = 80;
  138.   Guns[15].AGI_max = 90;
  139.   Guns[15].PC = 1;*/
  140.  
  141. Guns[16].name = "Homing Laser Beam";
  142. Guns[16].AT_min = 8;
  143. Guns[16].AT_max = 12;
  144. Guns[16].AGI_min = 20;
  145. Guns[16].AGI_max = 30;
  146. Guns[16].PC = 5;
  147.  
  148. Guns[17].name = "3-Round Burst";
  149. Guns[17].AT_min = 24;
  150. Guns[17].AT_max = 36;
  151. Guns[17].AGI_min = 20;
  152. Guns[17].AGI_max = 30;
  153. Guns[17].PC = 3;
  154.  
  155. Guns[18].name = "Missile";
  156. Guns[18].AT_min = 300;
  157. Guns[18].AT_max = 500;
  158. Guns[18].AGI_min = 160;
  159. Guns[18].AGI_max = 180;
  160. Guns[18].PC = 1;
  161.  
  162. Guns[19].name = "Mini Uzi";
  163. Guns[19].AT_min = 12;
  164. Guns[19].AT_max = 24;
  165. Guns[19].AGI_min = 5;
  166. Guns[19].AGI_max = 10;
  167. Guns[19].PC = 2;
  168.  
  169. Guns[20].name = "Scattergun";
  170. Guns[20].AT_min = 1;
  171. Guns[20].AT_max = 80;
  172. Guns[20].AGI_min = 50;
  173. Guns[20].AGI_max = 60;
  174. Guns[20].PC = 9;
  175.  
  176. Guns[21].name = "Hunting Gun";
  177. Guns[21].AT_min = 140;
  178. Guns[21].AT_max = 160;
  179. Guns[21].AGI_min = 50;
  180. Guns[21].AGI_max = 60;
  181. Guns[21].PC = 1;
  182.  
  183. /*Guns[22].name = "M9 Grenade";
  184.   Guns[22].AT_min = 18;
  185.   Guns[22].AT_max = 48;
  186.   Guns[22].AGI_min = 20;
  187.   Guns[22].AGI_max = 30;
  188.   Guns[22].PC = 1;*/
  189.  
  190. /*Guns[23].name = "Power Laser Gun";
  191.   Guns[23].AT_min = 24;
  192.   Guns[23].AT_max = 36;
  193.   Guns[23].AGI_min = 20;
  194.   Guns[23].AGI_max = 30;
  195.   Guns[23].PC = 1;*/
  196.  
  197. /*Guns[24].name = "Napalm Bomb";
  198.   Guns[24].AT_min = 0;
  199.   Guns[24].AT_max = 0;
  200.   Guns[24].AGI_min = 160;
  201.   Guns[24].AGI_max = 180;
  202.   Guns[24].PC = 1;*/
  203.  
  204. /*Guns[25].name = "Wave Cannon";
  205.   Guns[25].AT_min = 120;
  206.   Guns[25].AT_max = 180;
  207.   Guns[25].AGI_min = 80;
  208.   Guns[25].AGI_max = 90;
  209.   Guns[25].PC = 1;*/
  210.  
  211. Guns[26].name = "Pierce Homing";
  212. Guns[26].AT_min = 12;
  213. Guns[26].AT_max = 16;
  214. Guns[26].AGI_min = 20;
  215. Guns[26].AGI_max = 30;
  216. Guns[26].PC = 7;
  217.  
  218. Guns[27].name = "Magnum";
  219. Guns[27].AT_min = 80;
  220. Guns[27].AT_max = 120;
  221. Guns[27].AGI_min = 20;
  222. Guns[27].AGI_max = 30;
  223. Guns[27].PC = 1;
  224.  
  225. Guns[28].name = "Micro Uzi";
  226. Guns[28].AT_min = 16;
  227. Guns[28].AT_max = 32;
  228. Guns[28].AGI_min = 5;
  229. Guns[28].AGI_max = 10;
  230. Guns[28].PC = 3;
  231.  
  232. Guns[29].name = "Triple Shotgun";
  233. Guns[29].AT_min = 1;
  234. Guns[29].AT_max = 120;
  235. Guns[29].AGI_min = 50;
  236. Guns[29].AGI_max = 60;
  237. Guns[29].PC = 15;
  238.  
  239. Guns[30].name = "Rail Gun";
  240. Guns[30].AT_min = 300;
  241. Guns[30].AT_max = 320;
  242. Guns[30].AGI_min = 50;
  243. Guns[30].AGI_max = 60;
  244. Guns[30].PC = 1;
  245.  
  246. /*Guns[31].name = "Napalm Gun";
  247.   Guns[31].AT_min = 26;
  248.   Guns[31].AT_max = 96;
  249.   Guns[31].AGI_min = 70;
  250.   Guns[31].AGI_max = 80;
  251.   Guns[31].PC = 1;*/
  252.  
  253. /*Guns[32].name = "Slow Laser Gun";
  254.   Guns[32].AT_min = 32;
  255.   Guns[32].AT_max = 48;
  256.   Guns[32].AGI_min = 20;
  257.   Guns[32].AGI_max = 30;
  258.   Guns[32].PC = 1;*/
  259. }
  260.  
  261. // Sets values to the Gunner character
  262. void getStats(Character &Gunner1, int &LVL){
  263. std::cout << "Enter characters' level: ";
  264. std::cin >> LVL;
  265. std::cout << LVL << std::endl;
  266. Gunner1.STR = LVL - 1; // Evenly distribute STR and DEX
  267. Gunner1.DEX = LVL - 1;
  268. }
  269.  
  270.  
  271. // Calculates DPS for each gun equipped on the gunner character
  272. // How to get DPS: (AT + STR*2%) * (AGI / 2%*DEX)
  273. void calcDPS(Character Gunner1, Gun Guns[], int LVL){
  274. float DPS; // Damage per 60 frames
  275. float DPS_max = 0; // Maximum DPS
  276. int DPS_max_STR, DPS_max_DEX; // STR and DEX allocation for maximum DPS
  277. int AGImin, AGImax; // Minimum and maximum ATtack damage
  278. float AGI; // Average AGIlity (number of frames between shots)
  279. int ATmin, ATmax; // Minimum and maximum ATtack damage
  280. float AT; // Average ATtack damage
  281. int range = (LVL - 1) * 2; // Range of stats to calculate (currently set to go from 0 to max)
  282.  
  283. for (int i = 0; i < weapons; i++){ // Runs for the number of weapons
  284.  
  285. if (Guns[i].name == "") continue; // Skip over commented out Guns
  286.  
  287. for (int k = 0; k <= range; k++){ // Loop for going through full range of STR/DEX
  288.  
  289. // Calculates average AT
  290. ATmin = Guns[i].AT_min * (1 + 0.02 * (Gunner1.STR - (range/2 - k))); // Minimum AT calculation
  291. ATmax = Guns[i].AT_max * (1 + 0.02 * (Gunner1.STR - (range/2 - k))); // Maximum AT calculation
  292. AT = (ATmin + ATmax) / 2.; // Average AT calculation
  293.  
  294. // Calculates average AGI
  295. AGImin = Guns[i].AGI_min / (1 + 0.02 * (Gunner1.DEX + range/2 - k)); // Minimum AGI calculation
  296. if (AGImin < 5) AGImin = 5; // AGImin caps at 5
  297. AGImax = Guns[i].AGI_max / (1 + 0.02 * (Gunner1.DEX + range/2 - k)); // Maximum AGI calculation
  298. if (AGImax < 10) AGImax = 10; // AGImin caps at 10
  299. AGI = (AGImin + AGImax) / 2.; // Average AGI calculation
  300.  
  301. // Calculates average DPS
  302. DPS = AT * (60 / AGI);
  303.  
  304. // Calculates maximum DPS
  305. if (DPS > DPS_max){
  306. DPS_max = DPS; // Store maximum DPS
  307. DPS_max_STR = Gunner1.STR - (range/2 - k); // Store STR parameter of maximum DPS
  308. DPS_max_DEX = Gunner1.DEX + (range/2 - k); // Store DEX parameter of maximum DPS
  309. }
  310. }
  311.  
  312. // Outputs table of optimum STR/DEX allocation for maximum DPS of each Gun
  313. std::cout << "DPS max for " << std::setw(17) << Guns[i].name << ": ";
  314. std::cout << "STR " << std::setw(3) << DPS_max_STR; // STR
  315. std::cout << " DEX " << std::setw(3) << DPS_max_DEX; // DEX
  316. std::cout << " DPS = " << DPS_max * Guns[i].PC << std::endl; // DPS
  317. DPS_max = DPS_max_STR = DPS_max_DEX = 0; // Reset maximums
  318. }
  319. std::cout << std::endl;
  320. }
  321.  
  322. int main(){
  323. Character Gunner1; // Gunner character
  324. Gun Guns[weapons]; // Array of guns to calculate
  325. int LVL; // Level of your team
  326.  
  327. setGuns(Guns);
  328.  
  329. getStats(Gunner1, LVL);
  330. while (LVL){
  331. calcDPS(Gunner1, Guns, LVL);
  332. getStats(Gunner1, LVL);
  333. }
  334.  
  335. return 0;
  336. }
  337.  
Success #stdin #stdout 0.01s 5280KB
stdin
99
97
18
44
0
stdout
Enter characters' level: 99
DPS max for               Gun: STR 100  DEX  96  DPS = 90
DPS max for           Handgun: STR 100  DEX  96  DPS = 225
DPS max for    Submachine-gun: STR 194  DEX   2  DPS = 232
DPS max for           Shotgun: STR 103  DEX  93  DPS = 518.919
DPS max for             Rifle: STR  88  DEX 108  DPS = 300
DPS max for      Homing Laser: STR 100  DEX  96  DPS = 450
DPS max for           Beretta: STR 103  DEX  93  DPS = 686.25
DPS max for               Uzi: STR 196  DEX   0  DPS = 708
DPS max for         Remington: STR  88  DEX 108  DPS = 1425.45
DPS max for      Sniper Rifle: STR  88  DEX 108  DPS = 700
DPS max for Homing Laser Beam: STR 100  DEX  96  DPS = 1125
DPS max for     3-Round Burst: STR 103  DEX  93  DPS = 2058.75
DPS max for           Missile: STR 103  DEX  93  DPS = 1255.38
DPS max for          Mini Uzi: STR 196  DEX   0  DPS = 1416
DPS max for        Scattergun: STR  88  DEX 108  DPS = 3632.73
DPS max for       Hunting Gun: STR  88  DEX 108  DPS = 1503.64
DPS max for     Pierce Homing: STR 100  DEX  96  DPS = 2205
DPS max for            Magnum: STR 103  DEX  93  DPS = 2291.25
DPS max for         Micro Uzi: STR 196  DEX   0  DPS = 2820
DPS max for    Triple Shotgun: STR  88  DEX 108  DPS = 9081.82
DPS max for          Rail Gun: STR  88  DEX 108  DPS = 3109.09

Enter characters' level: 97
DPS max for               Gun: STR 100  DEX  92  DPS = 84.7059
DPS max for           Handgun: STR  96  DEX  96  DPS = 217.5
DPS max for    Submachine-gun: STR 188  DEX   4  DPS = 228
DPS max for           Shotgun: STR 103  DEX  89  DPS = 505.263
DPS max for             Rifle: STR  84  DEX 108  DPS = 290.909
DPS max for      Homing Laser: STR  96  DEX  96  DPS = 435
DPS max for           Beretta: STR  99  DEX  93  DPS = 667.5
DPS max for               Uzi: STR 192  DEX   0  DPS = 696
DPS max for         Remington: STR  84  DEX 108  DPS = 1387.27
DPS max for      Sniper Rifle: STR  84  DEX 108  DPS = 680
DPS max for Homing Laser Beam: STR  96  DEX  96  DPS = 1087.5
DPS max for     3-Round Burst: STR  99  DEX  93  DPS = 2002.5
DPS max for           Missile: STR  99  DEX  93  DPS = 1222.56
DPS max for          Mini Uzi: STR 192  DEX   0  DPS = 1392
DPS max for        Scattergun: STR  84  DEX 108  DPS = 3534.55
DPS max for       Hunting Gun: STR  84  DEX 108  DPS = 1460
DPS max for     Pierce Homing: STR  97  DEX  95  DPS = 2152.5
DPS max for            Magnum: STR  99  DEX  93  DPS = 2231.25
DPS max for         Micro Uzi: STR 191  DEX   1  DPS = 2772
DPS max for    Triple Shotgun: STR  84  DEX 108  DPS = 8809.09
DPS max for          Rail Gun: STR  84  DEX 108  DPS = 3018.18

Enter characters' level: 18
DPS max for               Gun: STR  25  DEX   9  DPS = 17.561
DPS max for           Handgun: STR  21  DEX  13  DPS = 44.2105
DPS max for    Submachine-gun: STR  32  DEX   2  DPS = 76
DPS max for           Shotgun: STR  10  DEX  24  DPS = 102.74
DPS max for             Rifle: STR  20  DEX  14  DPS = 59.2941
DPS max for      Homing Laser: STR  21  DEX  13  DPS = 88.4211
DPS max for           Beretta: STR  21  DEX  13  DPS = 134.211
DPS max for               Uzi: STR  34  DEX   0  DPS = 240
DPS max for         Remington: STR  14  DEX  20  DPS = 283.636
DPS max for      Sniper Rifle: STR  14  DEX  20  DPS = 138.701
DPS max for Homing Laser Beam: STR  21  DEX  13  DPS = 221.053
DPS max for     3-Round Burst: STR  21  DEX  13  DPS = 402.632
DPS max for           Missile: STR  15  DEX  19  DPS = 254.694
DPS max for          Mini Uzi: STR  34  DEX   0  DPS = 480
DPS max for        Scattergun: STR  14  DEX  20  DPS = 722.338
DPS max for       Hunting Gun: STR  14  DEX  20  DPS = 298.442
DPS max for     Pierce Homing: STR  17  DEX  17  DPS = 431.667
DPS max for            Magnum: STR  12  DEX  22  DPS = 449.091
DPS max for         Micro Uzi: STR  33  DEX   1  DPS = 948
DPS max for    Triple Shotgun: STR  14  DEX  20  DPS = 1800
DPS max for          Rail Gun: STR  14  DEX  20  DPS = 617.922

Enter characters' level: 44
DPS max for               Gun: STR  50  DEX  36  DPS = 34.2857
DPS max for           Handgun: STR  42  DEX  44  DPS = 86.4
DPS max for    Submachine-gun: STR  82  DEX   4  DPS = 124
DPS max for           Shotgun: STR  50  DEX  36  DPS = 200
DPS max for             Rifle: STR  45  DEX  41  DPS = 115.932
DPS max for      Homing Laser: STR  42  DEX  44  DPS = 172.8
DPS max for           Beretta: STR  42  DEX  44  DPS = 264
DPS max for               Uzi: STR  86  DEX   0  DPS = 388
DPS max for         Remington: STR  39  DEX  47  DPS = 549.818
DPS max for      Sniper Rifle: STR  39  DEX  47  DPS = 270.545
DPS max for Homing Laser Beam: STR  42  DEX  44  DPS = 432
DPS max for     3-Round Burst: STR  42  DEX  44  DPS = 792
DPS max for           Missile: STR  44  DEX  42  DPS = 493.115
DPS max for          Mini Uzi: STR  86  DEX   0  DPS = 776
DPS max for        Scattergun: STR  39  DEX  47  DPS = 1404
DPS max for       Hunting Gun: STR  39  DEX  47  DPS = 581.455
DPS max for     Pierce Homing: STR  35  DEX  51  DPS = 858.261
DPS max for            Magnum: STR  35  DEX  51  DPS = 886.957
DPS max for         Micro Uzi: STR  86  DEX   0  DPS = 1560
DPS max for    Triple Shotgun: STR  39  DEX  47  DPS = 3501.82
DPS max for          Rail Gun: STR  39  DEX  47  DPS = 1203.27

Enter characters' level: 0