Advertisement
Guest User

Untitled

a guest
Apr 26th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.84 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cmath>
  4. #include <cstring>
  5. #include <cstdlib>
  6. #include <stdio.h>
  7. #include <conio.h>
  8. using namespace std;
  9.  
  10.  
  11. struct human {
  12.  
  13. int hitpoints = 100, max_hitpoints = 100, regen_health = 4, hp_reduction;
  14. int mana = 15, max_mana = 15, regen_mana = 1, mana_reduction, damage_spell=20;
  15. int damage_sword, crit_chance, damage_crit;
  16. int evade ;
  17. int miss;
  18. //stats
  19.  
  20. bool shield; //if hero is holding shield
  21. bool not_fight = 1; //stat show purpose
  22. int direction = 1; //direction which player is facing
  23. int x=0, y=4; //position
  24. bool blood_sword; //if the sword is healing player by small amount
  25. float prefix = 1.0; //damage multiplier provided by weapon
  26. int score; //3 needed to progress to next stages
  27. int floor = 0; //stage
  28. };
  29. struct enemy {
  30.  
  31. string name;
  32.  
  33. int hitpoints=100, max_hitpoints;
  34. int mana, max_mana; //only boss has mana spell dmg and also offend
  35. int damage, crit_chance , damage_cri;
  36. int damage_spell=15,chance_damage_spell;
  37. //stats
  38.  
  39. int attack, defend, heal, spell, offend; //actions which enemy can take, offend lowers attack for this round and cout some shit
  40. };
  41.  
  42. int main()
  43. {
  44. srand( time( NULL ) );
  45. human player;
  46. enemy enemy;
  47. int escape;
  48. char spell_choose;
  49. int round=1;
  50.  
  51.  
  52. char option;
  53. /*int crit_chance;
  54.  
  55. // HERO
  56. int potion=10;
  57. int mana=15;
  58. int hp_reduction;
  59. int attack;
  60. int my_hp=100;
  61.  
  62. int fire_ball=20;
  63.  
  64. // enemy
  65. int enemy_attack;
  66. int enemy_hp=100;
  67. int enemy_crit_chance;*/
  68.  
  69.  
  70.  
  71. while ((player.hitpoints > 0 && enemy.hitpoints > 0) && escape != 0)
  72. {
  73.  
  74. player.crit_chance = rand()%100;
  75. enemy.crit_chance = rand()%100;
  76. player.evade = rand()%100;
  77. player.miss= rand()%100;
  78. enemy.damage=rand()%6+5;
  79. player.damage_sword=rand()%6+5;
  80. player.damage_crit=2*player.damage_sword;
  81.  
  82.  
  83. cout << "1. Attack" << endl;
  84. cout << "2. Fire Ball [20 dmg | cost: 10 mana]" << endl;
  85. cout << "3. Try to escape" << endl;
  86. cout << endl;
  87. cout << "HP: "<< player.hitpoints<<endl;
  88. cout << "Mana: "<< player.mana << endl;
  89. cout << "Enemy HP: "<< enemy.hitpoints<<endl;
  90. cout << "\tRound "<< round++ << endl;
  91. enemy.name="mimic";
  92. cout << endl;
  93. if(round==2){
  94. option = getch();
  95. }
  96.  
  97. if (enemy.name=="mimic")
  98. {
  99. bool special_attack=1;
  100. switch (option)
  101. {
  102. case '1':
  103.  
  104. // player attack
  105. if (player.miss > 15)
  106. {
  107.  
  108. if (player.crit_chance<16)
  109. {
  110. cout << "Crit! You deal " << (player.damage_sword*=2) << " dmg!";
  111. }
  112. else
  113. {
  114. cout << "You deal "<< player.damage_sword << " dmg!";
  115. }
  116. }
  117. else
  118. {
  119. cout << "You miss! ";
  120. player.damage_sword=0;
  121. }
  122. cout << endl;
  123.  
  124. // enemy attack
  125. if (player.evade >15)
  126. {
  127. if (enemy.hitpoints<40 && special_attack)
  128. {
  129. cout << "Mimic bite you! (-20 HP)";
  130. player.hitpoints-=20;
  131. enemy.hitpoints+=20;
  132. special_attack = 0;
  133.  
  134. }
  135. else
  136. {
  137. if (enemy.crit_chance<16)
  138. {
  139. cout << "Crit! You received "<< (enemy.damage*=2) << " dmg";
  140. }
  141. else
  142. {
  143. cout << "You received "<< enemy.damage<< " dmg";
  144. }
  145. }
  146.  
  147. }
  148. else
  149. {
  150. cout<< "You dodge!";
  151. enemy.damage=0;
  152. }
  153.  
  154. cout << endl << "========================="<< endl;
  155. // RESULT
  156. enemy.hitpoints = enemy.hitpoints - player.damage_sword;
  157. player.hitpoints = player.hitpoints - enemy.damage;
  158.  
  159. player.hitpoints+=player.regen_health;
  160. player.mana+=player.regen_mana;
  161. if (player.mana>15)
  162. {
  163. player.mana_reduction=player.mana-player.max_mana;
  164. player.mana-=player.mana_reduction;
  165. }
  166.  
  167. if (player.hitpoints>100)
  168. {
  169. player.hp_reduction=player.hitpoints-player.max_hitpoints;
  170. player.hitpoints-=player.hp_reduction;
  171.  
  172. }
  173.  
  174. cout<< endl;
  175. break;
  176.  
  177. case '2':
  178. if (player.mana>9)
  179. {
  180.  
  181.  
  182. cout << "You deal "<< player.damage_spell << " dmg!"<<endl;
  183.  
  184. //enemy attack
  185. if (player.evade >15)
  186. {
  187. if (enemy.crit_chance<16)
  188. {
  189. cout << "Crit! You received "<< (enemy.damage*=2) << " dmg";
  190. }
  191. else
  192. {
  193. cout << "You received "<< enemy.damage<< " dmg";
  194. }
  195. }
  196. else
  197. {
  198. cout<< "You dodge!";
  199. enemy.damage=0;
  200. }
  201.  
  202. cout << endl << "========================="<< endl;
  203. //RESULT
  204. enemy.hitpoints-=player.damage_spell;
  205. player.damage_spell==0;
  206. player.hitpoints = player.hitpoints - enemy.damage;
  207.  
  208. player.mana-=10;
  209. player.hitpoints+=player.regen_health;
  210. player.mana+=player.regen_mana;
  211. if (player.mana>15)
  212. {
  213. player.mana_reduction=player.mana-player.max_mana;
  214. player.mana-=player.mana_reduction;
  215. }
  216.  
  217. if (player.hitpoints>100)
  218. {
  219. player.hp_reduction=player.hitpoints-player.max_hitpoints;
  220. player.hitpoints-=player.hp_reduction;
  221.  
  222. }
  223.  
  224. }
  225. else
  226. {
  227. cout<< "You dont have enought mana!"<<endl;
  228.  
  229. round --;
  230. }
  231.  
  232. break;
  233.  
  234.  
  235.  
  236.  
  237. case '3':
  238. escape=rand()%10;
  239. if (escape==0)
  240. {
  241. cout << "You just ran away like a coward...";
  242. break;
  243.  
  244. }
  245. else
  246. {
  247. cout << "You didn't escape, so you have to go back and fight! (-10 HP)"<<endl;
  248. player.hitpoints-=10;
  249.  
  250.  
  251. }
  252. break;
  253.  
  254. default:
  255. cout << "Choose another option";
  256. round --;
  257. break;
  258.  
  259. }
  260. }
  261. else if (enemy.name=="boss")
  262. {
  263. enemy.offend=rand()%100;
  264. switch (option)
  265. {
  266. case '1':
  267.  
  268. // player attack
  269. if (player.miss > 15)
  270. {
  271.  
  272. if (player.crit_chance<16)
  273. {
  274. cout << "Crit! You deal " << (player.damage_sword*=2) << " dmg!";
  275. }
  276. else
  277. {
  278. cout << "You deal "<< player.damage_sword << " dmg!";
  279. }
  280. }
  281. else
  282. {
  283. cout << "You miss! ";
  284. player.damage_sword=0;
  285. }
  286. cout << endl;
  287.  
  288. // enemy attack
  289. if (player.evade >15)
  290. {
  291.  
  292. if(enemy.offend<10)
  293. {
  294. cout << "Jebac cie (Your dmg was reducted)";
  295. player.damage_sword-=10;
  296. if (player.damage_sword<0)
  297. {
  298. player.damage_sword = 0;
  299. }
  300. }
  301. else
  302. {
  303. if (enemy.crit_chance<16)
  304. {
  305. cout << "Crit! You received "<< (enemy.damage*=2) << " dmg";
  306. }
  307. else
  308. {
  309. cout << "You received "<< enemy.damage<< " dmg";
  310. }
  311. }
  312.  
  313.  
  314.  
  315. }
  316. else
  317. {
  318. cout<< "You dodge!";
  319. enemy.damage=0;
  320. }
  321.  
  322. cout << endl << "========================="<< endl;
  323. // RESULT
  324. enemy.hitpoints = enemy.hitpoints - player.damage_sword;
  325. player.hitpoints = player.hitpoints - enemy.damage;
  326.  
  327. player.hitpoints+=player.regen_health;
  328. player.mana+=player.regen_mana;
  329. if (player.mana>15)
  330. {
  331. player.mana_reduction=player.mana-player.max_mana;
  332. player.mana-=player.mana_reduction;
  333. }
  334.  
  335. if (player.hitpoints>100)
  336. {
  337. player.hp_reduction=player.hitpoints-player.max_hitpoints;
  338. player.hitpoints-=player.hp_reduction;
  339.  
  340. }
  341.  
  342. cout<< endl;
  343. break;
  344.  
  345. case '2':
  346. if (player.mana>9)
  347. {
  348.  
  349.  
  350. cout << "You deal "<< player.damage_spell << " dmg!"<<endl;
  351.  
  352. //enemy attack
  353. if (player.evade >15)
  354. {
  355. if (enemy.crit_chance<16)
  356. {
  357. cout << "Crit! You received "<< (enemy.damage*=2) << " dmg";
  358. }
  359. else
  360. {
  361. cout << "You received "<< enemy.damage<< " dmg";
  362. }
  363. }
  364. else
  365. {
  366. cout<< "You dodge!";
  367. enemy.damage=0;
  368. }
  369.  
  370. cout << endl << "========================="<< endl;
  371. //RESULT
  372. enemy.hitpoints-=player.damage_spell;
  373. player.damage_spell==0;
  374. player.hitpoints = player.hitpoints - enemy.damage;
  375.  
  376. player.mana-=10;
  377. player.hitpoints+=player.regen_health;
  378. player.mana+=player.regen_mana;
  379. if (player.mana>15)
  380. {
  381. player.mana_reduction=player.mana-player.max_mana;
  382. player.mana-=player.mana_reduction;
  383. }
  384.  
  385. if (player.hitpoints>100)
  386. {
  387. player.hp_reduction=player.hitpoints-player.max_hitpoints;
  388. player.hitpoints-=player.hp_reduction;
  389.  
  390. }
  391.  
  392. }
  393. else
  394. {
  395. cout<< "You dont have enought mana!"<<endl;
  396.  
  397. round --;
  398. }
  399.  
  400. break;
  401.  
  402.  
  403.  
  404.  
  405. case '3':
  406. escape=rand()%10;
  407. if (escape==0)
  408. {
  409. cout << "You just ran away like a coward...";
  410. break;
  411.  
  412. }
  413. else
  414. {
  415. cout << "You didn't escape, so you have to go back and fight! (-10 HP)"<<endl;
  416. player.hitpoints-=10;
  417.  
  418.  
  419. }
  420. break;
  421.  
  422. default:
  423. cout << "Choose another option";
  424. round --;
  425. break;
  426.  
  427. }
  428. }
  429. else
  430. {
  431.  
  432. }
  433.  
  434.  
  435.  
  436. option = getch();
  437. system ("cls");
  438.  
  439. }
  440. if (escape == 0)
  441. {
  442. cout << "You lost some coins along the way...";
  443. }
  444. else if (player.hitpoints > 0)
  445. {
  446. cout << "You defeated the opponent!";
  447. }
  448. else if (enemy.hitpoints>0)
  449. {
  450. cout << "GAME OVER" ;
  451. }
  452.  
  453.  
  454. getchar();
  455.  
  456. return 0;
  457. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement