Advertisement
Guest User

Untitled

a guest
Apr 26th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.60 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,attempts=4;
  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.  
  43.  
  44.  
  45. int main()
  46. {
  47. srand( time( NULL ) );
  48. human player;
  49. enemy enemy;
  50. int escape;
  51. int test = 4;
  52.  
  53. int round=1;
  54.  
  55.  
  56. char option;
  57.  
  58.  
  59.  
  60.  
  61. while ((player.hitpoints > 0 && enemy.hitpoints > 0) && escape != 0)
  62. {
  63.  
  64. player.crit_chance = rand()%100;
  65. enemy.crit_chance = rand()%100;
  66. player.evade = rand()%100;
  67. player.miss= rand()%100;
  68. enemy.damage=rand()%6+5;
  69. player.damage_sword=rand()%6+5;
  70. player.damage_crit=2*player.damage_sword;
  71.  
  72.  
  73. cout << "1. Attack" << endl;
  74. cout << "2. Fire Ball [20 dmg | cost: 10 mana]" << endl;
  75. cout << "3. Try to escape" << endl;
  76. cout << endl;
  77. cout << "HP: "<< player.hitpoints<<endl;
  78. cout << "Mana: "<< player.mana << endl;
  79. cout << "Enemy HP: "<< enemy.hitpoints<<endl;
  80. cout << "\tRound "<< round++ << endl;
  81. enemy.name="mimic";
  82. cout << endl;
  83. if(round==2){
  84. option = getch();
  85. }
  86.  
  87. if (enemy.name=="mimic") // MIMIC ==========================================================================================
  88. {
  89. bool special_attack=1;
  90.  
  91. switch (option)
  92. {
  93. case '1':
  94.  
  95. // player attack
  96. if (player.miss > 15)
  97. {
  98.  
  99. if (player.crit_chance<16)
  100. {
  101. cout << "Crit! You deal " << (player.damage_sword*=2) << " dmg!";
  102. }
  103. else
  104. {
  105. cout << "You deal "<< player.damage_sword << " dmg!";
  106. }
  107. }
  108. else
  109. {
  110. cout << "You miss! ";
  111. player.damage_sword=0;
  112. }
  113. cout << endl;
  114.  
  115. // enemy attack
  116. if (player.evade >15)
  117. {
  118. if (enemy.hitpoints<40 && special_attack)
  119. {
  120. cout << "Mimic bite you! (-20 HP)";
  121. player.hitpoints-=20;
  122. enemy.hitpoints+=20;
  123. special_attack = 0;
  124.  
  125. }
  126. else
  127. {
  128. if (enemy.crit_chance<16)
  129. {
  130. cout << "Crit! You received "<< (enemy.damage*=2) << " dmg";
  131. }
  132. else
  133. {
  134. cout << "You received "<< enemy.damage<< " dmg";
  135. }
  136. }
  137.  
  138. }
  139. else
  140. {
  141. cout<< "You dodge!";
  142. enemy.damage=0;
  143. }
  144.  
  145. cout << endl << "========================="<< endl;
  146. // RESULT
  147. enemy.hitpoints = enemy.hitpoints - player.damage_sword;
  148. player.hitpoints = player.hitpoints - enemy.damage;
  149.  
  150. player.hitpoints+=player.regen_health;
  151. player.mana+=player.regen_mana;
  152. if (player.mana>15)
  153. {
  154. player.mana_reduction=player.mana-player.max_mana;
  155. player.mana-=player.mana_reduction;
  156. }
  157.  
  158. if (player.hitpoints>100)
  159. {
  160. player.hp_reduction=player.hitpoints-player.max_hitpoints;
  161. player.hitpoints-=player.hp_reduction;
  162.  
  163. }
  164.  
  165. cout<< endl;
  166. break;
  167.  
  168. case '2':
  169. if (player.mana>9)
  170. {
  171.  
  172.  
  173. cout << "You deal "<< player.damage_spell << " dmg!"<<endl;
  174.  
  175. //enemy attack
  176. if (player.evade >15)
  177. {
  178. if (enemy.crit_chance<16)
  179. {
  180. cout << "Crit! You received "<< (enemy.damage*=2) << " dmg";
  181. }
  182. else
  183. {
  184. cout << "You received "<< enemy.damage<< " dmg";
  185. }
  186. }
  187. else
  188. {
  189. cout<< "You dodge!";
  190. enemy.damage=0;
  191. }
  192.  
  193. cout << endl << "========================="<< endl;
  194. //RESULT
  195. enemy.hitpoints-=player.damage_spell;
  196. player.damage_spell==0;
  197. player.hitpoints = player.hitpoints - enemy.damage;
  198.  
  199. player.mana-=10;
  200. player.hitpoints+=player.regen_health;
  201. player.mana+=player.regen_mana;
  202. if (player.mana>15)
  203. {
  204. player.mana_reduction=player.mana-player.max_mana;
  205. player.mana-=player.mana_reduction;
  206. }
  207.  
  208. if (player.hitpoints>100)
  209. {
  210. player.hp_reduction=player.hitpoints-player.max_hitpoints;
  211. player.hitpoints-=player.hp_reduction;
  212.  
  213. }
  214.  
  215. }
  216. else
  217. {
  218. cout<< "You dont have enought mana!"<<endl;
  219.  
  220. round --;
  221. }
  222.  
  223. break;
  224.  
  225.  
  226.  
  227.  
  228. case '3':
  229.  
  230.  
  231. if (test>0)
  232. {
  233. escape=rand()%10;
  234. if (escape==0)
  235. {
  236. cout << "You just ran away like a coward...";
  237.  
  238.  
  239. }
  240. else
  241. {
  242. cout << "You didn't escape, so you have to go back and fight! (-10 HP)"<<endl;
  243. player.hitpoints-=10;
  244. test--;
  245. }
  246. }
  247. else
  248. {
  249. cout << "You have too many attempts";
  250. round --;
  251. }
  252.  
  253.  
  254. break;
  255.  
  256. default:
  257. cout << "Choose another option";
  258. round --;
  259. break;
  260.  
  261. }
  262. }
  263. else if (enemy.name=="boss") //BOSS==========================================================================
  264. {
  265. enemy.offend=rand()%100;
  266. enemy.chance_damage_spell=rand()%100;
  267. switch (option)
  268. {
  269. case '1':
  270.  
  271. // player attack
  272. if (player.miss > 15)
  273. {
  274. if (player.crit_chance<16)
  275. {
  276. cout << "Crit! You deal " << (player.damage_sword*=2) << " dmg!";
  277. }
  278. else
  279. {
  280. cout << "You deal "<< player.damage_sword << " dmg!";
  281. }
  282. }
  283. else
  284. {
  285. cout << "You miss! ";
  286. player.damage_sword=0;
  287. }
  288. cout << endl;
  289.  
  290. // enemy attack
  291. if (player.evade >15)
  292. {
  293. if (enemy.attempts>0)
  294. {
  295. if (enemy.chance_damage_spell<10)
  296. {
  297. cout << "Mind Blast! (-15 hp)";
  298. enemy.damage=enemy.damage_spell;
  299. enemy.attempts--;
  300. }
  301. else
  302. {
  303. if(enemy.offend<10)
  304. {
  305. cout << "Offend (Your dmg was reducted)";
  306. player.damage_sword-=10;
  307.  
  308. if (player.damage_sword<0)
  309. {
  310. player.damage_sword = 0;
  311. }
  312. }
  313. else
  314. {
  315. if (enemy.crit_chance<16)
  316. {
  317. cout << "Crit! You received "<< (enemy.damage*=2) << " dmg";
  318. }
  319. else
  320. {
  321. cout << "You received "<< enemy.damage<< " dmg";
  322. }
  323. }
  324. }
  325.  
  326. }
  327.  
  328. else
  329. {
  330. if(enemy.offend<10)
  331. {
  332. cout << "Offend (Your dmg was reducted)";
  333. player.damage_sword-=10;
  334. if (player.damage_sword<0)
  335. {
  336. player.damage_sword = 0;
  337. }
  338. }
  339. else
  340. {
  341. if (enemy.crit_chance<16)
  342. {
  343. cout << "Crit! You received "<< (enemy.damage*=2) << " dmg";
  344. }
  345. else
  346. {
  347. cout << "You received "<< enemy.damage<< " dmg";
  348. }
  349. }
  350. }
  351. }
  352. else
  353. {
  354. cout<< "You dodge!";
  355. enemy.damage=0;
  356. }
  357.  
  358. cout << endl << "========================="<< endl;
  359. // RESULT
  360. enemy.hitpoints = enemy.hitpoints - player.damage_sword;
  361. player.hitpoints = player.hitpoints - enemy.damage;
  362.  
  363. player.hitpoints+=player.regen_health;
  364. player.mana+=player.regen_mana;
  365. if (player.mana>15)
  366. {
  367. player.mana_reduction=player.mana-player.max_mana;
  368. player.mana-=player.mana_reduction;
  369. }
  370.  
  371. if (player.hitpoints>100)
  372. {
  373. player.hp_reduction=player.hitpoints-player.max_hitpoints;
  374. player.hitpoints-=player.hp_reduction;
  375.  
  376. }
  377.  
  378. cout<< endl;
  379. break;
  380.  
  381. case '2':
  382. if (player.mana>9)
  383. {
  384.  
  385.  
  386. cout << "You deal "<< player.damage_spell << " dmg!"<<endl;
  387.  
  388. //enemy attack
  389. if (player.evade >15)
  390. {
  391. if (enemy.attempts>0)
  392. {
  393. if (enemy.chance_damage_spell<10)
  394. {
  395. cout << "Mind Blast! (-15 hp)";
  396. enemy.damage=enemy.damage_spell;
  397. enemy.attempts--;
  398. }
  399. else
  400. {
  401. if(enemy.offend<10)
  402. {
  403. cout << "Offend (Your dmg was reducted)";
  404. player.damage_sword-=10;
  405.  
  406. if (player.damage_sword<0)
  407. {
  408. player.damage_sword = 0;
  409. }
  410. }
  411. else
  412. {
  413. if (enemy.crit_chance<16)
  414. {
  415. cout << "Crit! You received "<< (enemy.damage*=2) << " dmg";
  416. }
  417. else
  418. {
  419. cout << "You received "<< enemy.damage<< " dmg";
  420. }
  421. }
  422. }
  423.  
  424. }
  425.  
  426.  
  427.  
  428. else
  429. {
  430. if(enemy.offend<10)
  431. {
  432. cout << "Offend (Your dmg was reducted)";
  433. player.damage_sword-=10;
  434.  
  435. if (player.damage_sword<0)
  436. {
  437. player.damage_sword = 0;
  438. }
  439. }
  440. else
  441. {
  442. if (enemy.crit_chance<16)
  443. {
  444. cout << "Crit! You received "<< (enemy.damage*=2) << " dmg";
  445. }
  446. else
  447. {
  448. cout << "You received "<< enemy.damage<< " dmg";
  449. }
  450. }
  451. }
  452.  
  453. }
  454. else
  455. {
  456. cout<< "You dodge!";
  457. enemy.damage=0;
  458. }
  459.  
  460. cout << endl << "========================="<< endl;
  461. //RESULT
  462. enemy.hitpoints-=player.damage_spell;
  463. player.damage_spell==0;
  464. player.hitpoints = player.hitpoints - enemy.damage;
  465.  
  466. player.mana-=10;
  467. player.hitpoints+=player.regen_health;
  468. player.mana+=player.regen_mana;
  469. if (player.mana>15)
  470. {
  471. player.mana_reduction=player.mana-player.max_mana;
  472. player.mana-=player.mana_reduction;
  473. }
  474.  
  475. if (player.hitpoints>100)
  476. {
  477. player.hp_reduction=player.hitpoints-player.max_hitpoints;
  478. player.hitpoints-=player.hp_reduction;
  479.  
  480. }
  481.  
  482. }
  483. else
  484. {
  485. cout<< "You dont have enought mana!"<<endl;
  486.  
  487. round --;
  488. }
  489.  
  490. break;
  491.  
  492.  
  493.  
  494.  
  495. case '3':
  496.  
  497. if (test>0)
  498. {
  499. escape=rand()%10;
  500. if (escape==0)
  501. {
  502. cout << "You just ran away like a coward...";
  503.  
  504.  
  505. }
  506. else
  507. {
  508. cout << "You didn't escape, so you have to go back and fight! (-10 HP)"<<endl;
  509. player.hitpoints-=10;
  510. test--;
  511. }
  512. }
  513. else
  514. {
  515. cout << "You have too many attempts";
  516. round --;
  517. }
  518.  
  519.  
  520. break;
  521.  
  522. default:
  523. cout << "Choose another option";
  524. round --;
  525. break;
  526.  
  527. }
  528. }
  529. else // NORMAL ===================================================================================
  530. {
  531. {
  532.  
  533. switch (option)
  534. {
  535. case '1':
  536.  
  537. // player attack
  538. if (player.miss > 15)
  539. {
  540.  
  541. if (player.crit_chance<16)
  542. {
  543. cout << "Crit! You deal " << (player.damage_sword*=2) << " dmg!";
  544. }
  545. else
  546. {
  547. cout << "You deal "<< player.damage_sword << " dmg!";
  548. }
  549. }
  550. else
  551. {
  552. cout << "You miss! ";
  553. player.damage_sword=0;
  554. }
  555. cout << endl;
  556.  
  557. // enemy attack
  558. if (player.evade >15)
  559. {
  560.  
  561.  
  562. if (enemy.crit_chance<16)
  563. {
  564. cout << "Crit! You received "<< (enemy.damage*=2) << " dmg";
  565. }
  566. else
  567. {
  568. cout << "You received "<< enemy.damage<< " dmg";
  569. }
  570.  
  571.  
  572. }
  573. else
  574. {
  575. cout<< "You dodge!";
  576. enemy.damage=0;
  577. }
  578.  
  579. cout << endl << "========================="<< endl;
  580. // RESULT
  581. enemy.hitpoints = enemy.hitpoints - player.damage_sword;
  582. player.hitpoints = player.hitpoints - enemy.damage;
  583.  
  584. player.hitpoints+=player.regen_health;
  585. player.mana+=player.regen_mana;
  586. if (player.mana>15)
  587. {
  588. player.mana_reduction=player.mana-player.max_mana;
  589. player.mana-=player.mana_reduction;
  590. }
  591.  
  592. if (player.hitpoints>100)
  593. {
  594. player.hp_reduction=player.hitpoints-player.max_hitpoints;
  595. player.hitpoints-=player.hp_reduction;
  596.  
  597. }
  598.  
  599. cout<< endl;
  600. break;
  601.  
  602. case '2':
  603. if (player.mana>9)
  604. {
  605.  
  606.  
  607. cout << "You deal "<< player.damage_spell << " dmg!"<<endl;
  608.  
  609. //enemy attack
  610. if (player.evade >15)
  611. {
  612. if (enemy.crit_chance<16)
  613. {
  614. cout << "Crit! You received "<< (enemy.damage*=2) << " dmg";
  615. }
  616. else
  617. {
  618. cout << "You received "<< enemy.damage<< " dmg";
  619. }
  620. }
  621. else
  622. {
  623. cout<< "You dodge!";
  624. enemy.damage=0;
  625. }
  626.  
  627. cout << endl << "========================="<< endl;
  628. //RESULT
  629. enemy.hitpoints-=player.damage_spell;
  630. player.damage_spell==0;
  631. player.hitpoints = player.hitpoints - enemy.damage;
  632.  
  633. player.mana-=10;
  634. player.hitpoints+=player.regen_health;
  635. player.mana+=player.regen_mana;
  636. if (player.mana>15)
  637. {
  638. player.mana_reduction=player.mana-player.max_mana;
  639. player.mana-=player.mana_reduction;
  640. }
  641.  
  642. if (player.hitpoints>100)
  643. {
  644. player.hp_reduction=player.hitpoints-player.max_hitpoints;
  645. player.hitpoints-=player.hp_reduction;
  646.  
  647. }
  648.  
  649. }
  650. else
  651. {
  652. cout<< "You dont have enought mana!"<<endl;
  653.  
  654. round --;
  655. }
  656.  
  657. break;
  658.  
  659.  
  660.  
  661.  
  662. case '3':
  663.  
  664. if (test>0)
  665. {
  666. escape=rand()%10;
  667. if (escape==0)
  668. {
  669. cout << "You just ran away like a coward...";
  670.  
  671.  
  672. }
  673. else
  674. {
  675. cout << "You didn't escape, so you have to go back and fight! (-10 HP)"<<endl;
  676. player.hitpoints-=10;
  677. test--;
  678. }
  679. }
  680. else
  681. {
  682. cout << "You have too many attempts";
  683. round --;
  684. }
  685.  
  686.  
  687. break;
  688. default:
  689. cout << "Choose another option";
  690. round --;
  691. break;
  692.  
  693. }
  694. }
  695. }
  696.  
  697.  
  698.  
  699. option = getch();
  700. system ("cls");
  701.  
  702. }
  703. if (escape == 0)
  704. {
  705. cout << "You lost some coins along the way...";
  706. }
  707. else if (player.hitpoints > 0)
  708. {
  709. cout << "You defeated the opponent!";
  710. }
  711. else if (enemy.hitpoints>0)
  712. {
  713. cout << "GAME OVER" ;
  714. }
  715.  
  716.  
  717. getchar();
  718.  
  719. return 0;
  720. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement