notjacob

c++ game pre2

Nov 22nd, 2019
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. int main() {
  4. srand(time(NULL));
  5. int critChance = rand() % 20 + 1;
  6.  
  7. int player = 0;
  8. int dragon = 0;
  9. int worm = 0;
  10.  
  11. int attacking = 0;
  12. bool dead = false;
  13. bool restart = false;
  14. int health = 10;
  15. std::string attack1;
  16. std::string attack2;
  17. std::string attack3;
  18. //classes
  19. int knight = 1;
  20. int mage = 2;
  21. int brute = 3;
  22.  
  23. int ismage = 0;
  24. int isknight = 0;
  25. int isbrute = 0;
  26.  
  27. //knight attacks
  28. int slash = 0;
  29. int swing = 0;
  30. int stab = 0;
  31.  
  32. //mage attacks
  33. int fireball = 0;
  34. int poison = 0;
  35. int lightning = 0;
  36.  
  37. //brute attacks
  38. int maul = 0;
  39. int beat = 0;
  40. int clobber = 0;
  41.  
  42. //dragon attacks
  43. int burn = 0;
  44. int torture = 0;
  45. int roast = 0;
  46.  
  47. //worm attacks
  48. int suck = 0;
  49. int consume = 0;
  50. int bury = 0;
  51.  
  52. //-----------------------------------------------
  53. //start story
  54. int answer1 = 0;
  55. int answer2 = 0;
  56. int answer3 = 0;
  57. int max = 0;
  58. dead = true;
  59. while (dead == true) {
  60. dead = false;
  61. std::cout << "==========================\nWelcome to the story!\n==========================\n";
  62. std::cout << "Here you will be given a quiz, which will select your class!\n";
  63. std::cout << "==========================";
  64. std::cout << "Q1) How do you prefer to handle situations?\n\n1. With Honor\n2. With Knowledge\n3. With Force\n";
  65. std::cin >> answer1;
  66.  
  67. if (answer1 == 1) {
  68. isknight++;
  69. }
  70. else if (answer1 == 2) {
  71. ismage++;
  72. }
  73. else if (answer1 == 3) {
  74. isbrute++;
  75. }
  76. else {
  77. std::cout << "Invalid Answer\n";
  78. }
  79. //---------------------------------------------
  80.  
  81. std::cout << "Q2) Which quality do you value most?\n\n1. strength\n2. honor\n3. wisdom\n";
  82. std::cin >> answer2;
  83.  
  84. if (answer2 == 1) {
  85. isbrute++;
  86. }
  87. else if (answer2 == 2) {
  88. isknight++;
  89. }
  90. else if (answer2 == 3) {
  91. ismage++;
  92. }
  93. else {
  94. std::cout << "Invalid Answer\n";
  95. }
  96. //---------------------------------------------
  97. std::cout << "Q3) If you were being attacked by someone, what would you do?\n\n1. Freeze them with your ice spell\n2. honor your vows and parry them like a proper servant of the king\n3. beat them to death\n";
  98. std::cin >> answer3;
  99.  
  100. if (answer3 == 1) {
  101. ismage++;
  102. }
  103. else if (answer3 == 2) {
  104. isknight++;
  105. }
  106. else if (answer3 == 3) {
  107. isbrute++;
  108. }
  109. else {
  110. std::cout << "Invalid Answer\n";
  111. }
  112. //---------------------------------------------
  113. std::string classtype;
  114.  
  115. if (ismage > max) {
  116. max = ismage;
  117. classtype = "Mage";
  118. player = 2;
  119. }
  120. if (isbrute > max) {
  121. max = isbrute;
  122. classtype = "Brute";
  123. player = 3;
  124. }
  125. if (isknight > max) {
  126. max = isknight;
  127. classtype = "Knight";
  128. player = 1;
  129. }
  130. std::cout << "You have been assigned the class " << classtype << "! Good luck!\n";
  131.  
  132. //STORYLINE
  133. //======================================================
  134. int beginn = 0;
  135. int begin = 0;
  136. while (begin == 0) {
  137. std::cout << "Ready to begin?\n1) yes\n2) no\n";
  138. std::cin >> beginn;
  139. begin = 1;
  140. if (beginn == 1) {
  141. std::cout << "Starting the story!\n";
  142. begin = 2;
  143. }
  144. else if (beginn == 2) {
  145. std::cout << "Ok! Tell us when you are ready!\n";
  146. begin = 0;
  147. }
  148. else {
  149. std::cout << "Invalid Option\n";
  150. begin = 0;
  151. }
  152. }
  153. while (begin == 2) {
  154. if (player == 2) {
  155. std::string ma1 = "fireball";
  156. std::string ma2 = "poison";
  157. std::string ma3 = "lightning";
  158. int returntodoor = 0;
  159. int gotobeginquest = 0;
  160. int mtcheck = 0;
  161. int answer4 = 0;
  162. int answer5 = 0;
  163. int answer6 = 0;
  164. begin = 3;
  165.  
  166.  
  167. std::cout << "'Ah, what a beautiful morning' you say, rising out of bed.\n";
  168. std::cout << "You open your book to where you left off last night.\n";
  169. std::cout << "Suddenly, you hear a knock at the door\n";
  170. returntodoor = 1;
  171. while (returntodoor == 1) {
  172.  
  173. std::cout << "Go to the door? (checkpoint)\n1. Yes\n2.No\n";
  174. std::cin >> answer4;
  175. returntodoor = 0;
  176.  
  177. if (answer4 == 2) {
  178. std::cout << "You feel like going to the door would be for the better\n";
  179. returntodoor = 1;
  180. }
  181.  
  182.  
  183.  
  184. if (answer4 == 1) {
  185. returntodoor = 0;
  186. std::cout << "You see a boy holding a newspaper standing at your door.\n";
  187. std::cout << "You take the newspaper and read it.\n";
  188. std::cout << "'UNKNOWN TERROR RAVAGING KINGDOM! Killer expected to receive opulent reward.'\n";
  189. std::cout << "The mentioned lucrative reward intrigues you.\n";
  190. std::cout << "You decide to speak to the sheriff. He probably knows something.\n";
  191. while (gotobeginquest == 0) {
  192. std::cout << "Speak to the sheriff?\n1. yes\n2. no\n";
  193. std::cin >> answer5;
  194. gotobeginquest = 1;
  195. if (answer5 == 2) {
  196. std::cout << "You go back to bed. The Kingdom is obliterated by a powerful beast. You die.\n";
  197. returntodoor = 1;
  198. }
  199. else if (answer5 == 1) {
  200. dead = false;
  201. std::cout << "You visit the sheriff. He instructs you to go through the mountains to find your foe.\n";
  202. std::cout << "Head to the mountains?\n1) yes\n2) no\n";
  203. std::cin >> answer6;
  204. if (answer6 == 2) {
  205. std::cout << "You decide today is a lazy day, and go back to bed. The Kingdom is ravaged by a ferocious beast. You die.\n";
  206. returntodoor = 1;
  207.  
  208. }
  209.  
  210. else if (answer6 == 1) {
  211. int answer7 = 0;
  212. dead = false;
  213. returntodoor = 0;
  214. std::cout << "In the height of the mountains, you see some fur poking out from behind a rock.\n";
  215. std::cout << "Investigate?\n1) Yes\n2) No\n";
  216. std::cin >> answer7;
  217. if (answer7 == 2) {
  218. std::cout << "You turn your back, and are mauled by a crazy wolf. You die.\n";
  219. returntodoor = 1;
  220. }
  221.  
  222. else if (answer7 == 1) {
  223. int answer8 = 0;
  224. std::cout << "A crazed Wolf jumps out at you!\n\n1) attack\n2) bargain\n3) run";
  225. std::cin >> answer8;
  226.  
  227. if (answer8 == 3) {
  228. std::cout << "You run.\n";
  229. returntodoor = 1;
  230. }
  231. else if (answer8 == 2) {
  232. int gotocave = 0;
  233. std::cout << "You bargain with the wolf.\n\nYou agree to go through a cave instead of disrupting the wolves.";
  234. gotocave = 1;
  235.  
  236.  
  237. }
  238. else if (answer8 == 1) {
  239. int usedattack = 0;
  240. int enemyhealth = 10;
  241. int playerhealth = 10;
  242. int a1dmg = 0;
  243. int a3dmg = 0;
  244. int a2dmg = 0;
  245. int iscrit = 0;
  246. int attackloop = 0;
  247. int enemydead1 = 0;
  248. std::cout << "Battle!\n\n";
  249. attackloop = 1;
  250. while (attackloop = 1) {
  251. attackloop = 0;
  252. std::cout << "Select your attack:\n" << "1) " << ma1 << "\n2) " << ma2 << "\n3) " << ma3 << "\n";
  253. std::cin >> usedattack;
  254.  
  255. if (usedattack == 1) {
  256. std::cout << "Used fireball!\n";
  257. a1dmg = rand() % 9 + 1;
  258. iscrit = rand() % 5 + 1;
  259. if (iscrit == 3) {
  260. std::cout << "Critical hit! Damage doubled!\n";
  261. enemyhealth = enemyhealth - a1dmg * 2;
  262. iscrit == 0;
  263. if (enemyhealth == 0) {
  264. std::cout << "Your enemy is dead!";
  265. usedattack = 0;
  266. enemydead1 = 1;
  267. }
  268. else {
  269. if (enemyhealth != 0)
  270. std::cout << "Your enemy is on " << enemyhealth << " health.";
  271. usedattack = 0;
  272. attackloop = 1;
  273. }
  274. }
  275. else {
  276. enemyhealth = enemyhealth - a1dmg;
  277. if (enemyhealth == 0) {
  278. std::cout << "Your enemy is dead!";
  279. usedattack = 0;
  280. enemydead1 = 1;
  281. }
  282. else if (enemyhealth != 0) {
  283. std::cout << "Your enemy is on " << enemyhealth << " health.";
  284. usedattack = 0;
  285. attackloop = 1;
  286. }
  287. else {
  288. std::cout << "Your enemy is dead!";
  289. usedattack = 0;
  290. enemydead1 = 1;
  291. attackloop = 0;
  292.  
  293. }
  294.  
  295. }
  296.  
  297. }
  298. }
  299.  
  300.  
  301.  
  302.  
  303.  
  304. }
  305.  
  306.  
  307.  
  308.  
  309.  
  310. }
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320. }
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331. }
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344. }
  345.  
  346.  
  347. }
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364. }
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382. }
  383. }
  384. }
  385. }
Advertisement
Add Comment
Please, Sign In to add comment