Advertisement
Guest User

Untitled

a guest
Jul 11th, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.17 KB | None | 0 0
  1. // ConsoleApplication6.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <stdlib.h>
  7. #include <string>
  8. #include <stdio.h> /* printf, NULL */
  9. #include <stdlib.h> /* srand, rand */
  10. #include <time.h> /* time */
  11. using namespace std;
  12.  
  13.  
  14. int main() {
  15. string confirmBattle;
  16. string itemOne;
  17. string itemTwo;
  18. string name;
  19. double humanHealth = 60.00;
  20. double dragonHealth = 100.00;
  21. double hitRand;
  22. string ropesyn;
  23. srand(time(NULL));
  24.  
  25.  
  26.  
  27. cout << "Welcome to Dragon Hunter. Press enter your name. \n \n";
  28. cin >> name;
  29. cout << "\nNarrator: The captain approaches. \n \n";
  30. cout << "Captain: A dragon has attacked our village. You have a moral obligation to go " << endl << "out and defend your citizens.Grab your weapons, and battle! You can do it, " << name << "." << endl << "\nDo you understand ? (yes or no)" << endl;
  31. cin >> confirmBattle;
  32.  
  33. if (confirmBattle == "yes")
  34. {
  35. cout << "\nCaptain: Glad to hear, "<< name << " ." << "Here's a sword and a shield. Gather any other \nweapons you need from the barracks.\n" << endl << "You nod your head in approval.\n ";
  36. cout << "\nNarrator: You go to the barracks and you have space in your bag to take two \nother items.\n\nYou see a set of ropes, a helmet, and a two - handed longsword. Pick your first item, then your second. \n" << endl;
  37. cin >> itemOne;
  38. cin >> itemTwo;
  39.  
  40. cout << "\nInteresting choices, " << itemOne << " and " << itemTwo << ".\n\n";
  41.  
  42. cout << "Narrator: You run on the field. You notice most of the men have fled the field, but you refuse to do the same.\n\n" << endl;
  43.  
  44. cout << "Dragon: ARRRRRRRRRRRRRRRRRGHHH! *spits fire directly at your face*\n\n" << endl;
  45.  
  46. if (itemOne == "helmet" || itemTwo == "helmet")
  47. {
  48. cout << "Your helmet came to your support, and you only took minor damage \n\n" << endl;
  49. humanHealth -= 5;
  50. }
  51. else
  52. {
  53. cout << "Narrator: You took major damage, but fortunately the dragon missed a majority of his illuminated fire-breath. You now wish you took the helmet for aid.\n\n" << endl;
  54. humanHealth -= 20;
  55. }
  56. cout << "Narrator: Time to begin your fight. You take out your sword the captain handed you and begin fighting. \n\nBe aware: anytime you have an unsuccessful hit, the dragon will hit you.\n\n";
  57.  
  58. do {
  59. hitRand = ("Random number: %d\n", rand() % 100);
  60.  
  61. if (85 >= hitRand >= 30) {
  62. cout << "You hit the dragon! He took some damage.\n\n" << endl;
  63. dragonHealth = dragonHealth - 20;
  64.  
  65. }
  66. else if (hitRand > 85) {
  67. cout << "WOOO! Major hit on the dragon. You notice the dragon feels major pain.\n\n";
  68. dragonHealth = dragonHealth - 40;
  69. }
  70. else {
  71. cout << "Miserable move. You completely missed the dragon and he launched a successful counter that led to him giving you major damage.\n\n" << endl;
  72. humanHealth = humanHealth - 18;
  73. }
  74. if (humanHealth < 30 && itemOne != "helmet" && itemOne != " two-handed longsword" && itemTwo != "two-handed longsword" && itemTwo != "helmet") {
  75. cout << "\nWould you like to use your ropes?\n\n";
  76. cin >> ropesyn;
  77. if (ropesyn == "yes") {
  78. cout << "Good choice. You made the dragon fall to the floor with a trap and gave it damage.\n\n";
  79. dragonHealth = dragonHealth - 25;
  80. }
  81. }
  82. else if (humanHealth < 30 && (itemOne == "two-handed longsword" || itemTwo == "two-handed longsword")) {
  83. cout << "\n Your sword broke. You are now using your longsword from the barracks and are dealing major damage.\n\n";
  84. dragonHealth = dragonHealth - 25;
  85. }
  86. if (humanHealth <= 0 || dragonHealth <= 0) {
  87. break;
  88. }
  89. } while (1);
  90.  
  91. if (humanHealth <= 0)
  92. {
  93. cout << "You died. You were not the hero the village needed." << endl;
  94. }
  95. else if (dragonHealth <= 0)
  96. {
  97. cout << "\n\nYou won! The dragon has fallen to the floor, and the town rejoice. You have been given many accolades for your heroic actions.\n\n Job well done!" << endl;
  98. }
  99. }
  100. else if (confirmBattle == "no") {
  101. cout << "Your village's military could not defeat the dragon. Your village goes extinct.";
  102. cout << "By Alexander Tekle - 7/11/14";
  103. }
  104. getchar();
  105. int a;
  106. cin >> a;
  107. return 0;
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement