4rl3fd

RPG game

Feb 14th, 2020
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.07 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <cstdlib>
  5. #include <ctime>
  6. #include <unistd.h>
  7. using namespace std;
  8. int rhp , dahp ,smhp , ohp , dlhp;
  9. int main();
  10. int score;
  11. int hp = 50;
  12. void game(void);
  13. void credits(void);
  14. void truewin (void)
  15. {
  16. cout << "CONGRAGULATIONS!" << endl;
  17. cout << "YOU WIN!" << endl;
  18. credits();
  19. main();
  20. }
  21. void win (void)
  22. {
  23. cout << "WIN" << endl;
  24. sleep(1);
  25. cout<< "hp: " << hp << endl;
  26. cout << "score: " << score << endl;
  27. }
  28. void lose(void)
  29. {
  30. cout << "LOSE" << endl;
  31. sleep(1);
  32. cout<< "hp: " << hp << endl;
  33. sleep(1);
  34. credits();
  35. }
  36. void esc(void)
  37. {
  38. cout << "YOU ESCAPED..." << endl;
  39. sleep(1);
  40. cout<< "hp: " << hp << endl;
  41. }
  42. void ROTSALA(void)
  43. {
  44. rhp = 25;
  45. label:
  46. int atk;
  47. cout << "ROTSALA APPEARS!" << endl;
  48. cout << endl;
  49. cout << "STATS:"<< endl;
  50. cout << "hp: " << hp << endl;
  51. cout << "ehp: " << rhp << endl;
  52. cout << endl;
  53. cout << "ATTACKS:" << endl;
  54. cout << "(1) sword attack" << endl;
  55. cout <<"(2) rain of arrows" << endl;
  56. cout << "(3) dark ritual" << endl;
  57. cout << "(4) summon healer" << endl;
  58. cout << "(5) escape" << endl;
  59. cin >> atk;
  60. if (atk == 1){
  61. cout << "You attack ROTSALA with your sword" << endl;
  62. rhp -= rand()%5;
  63. cout << "ROTSALA uses spear attack" << endl;
  64. hp -= rand()% 5;
  65. if (rhp <= 0){
  66. win();
  67.  
  68. score += 50;
  69. game();
  70. }
  71. if (hp <= 0){
  72. lose();
  73. }
  74. }
  75. if (atk == 2){
  76. cout << "you activated arrow rain "<< endl;
  77. rhp -= rand()%10;
  78. hp-= rand()%5;
  79. cout << "ROTSALA heals" << endl;
  80. rhp += rand()%5;
  81. if (rhp <= 0){
  82. win();
  83.  
  84. score += 50;
  85. game();
  86. }
  87. if (hp <= 0){
  88. lose();
  89. }
  90. }
  91. if (atk == 3){
  92. cout << "you did a dark ritual" << endl;
  93. if (rand()% 10 >= 3){
  94. rhp -= rand()%20;
  95. } else {
  96. cout << "It did not work" << endl;
  97. }
  98. cout << "ROTSALA throws fireballs " << endl;
  99. hp -= rand()% 10;
  100. if (rhp <= 0){
  101. win();
  102.  
  103. score += 50;
  104. game();
  105. }
  106. if (hp <= 0){
  107. lose();
  108. }
  109. }
  110. if (atk == 4){
  111. cout << "you healed" << endl;
  112. hp += rand()% 15;
  113. cout << "ROTSALA throws His spear " << endl;
  114. hp -= rand()% 7;
  115. if (rhp <= 0){
  116. win();
  117.  
  118. score+= 50;
  119. game();
  120. }
  121. if (hp <= 0){
  122. lose();
  123. }
  124. }
  125. if (atk == 5){
  126. if (rand()% 10 >= 5){
  127. esc();
  128. game();
  129. }
  130. cout << "YOU DID NOT ESCAPE" << endl;
  131. cout << "ROTSALA HEALS" << endl;
  132. rhp += rand()% 15;
  133. }
  134. goto label;
  135. }
  136. void DON (void)
  137. {
  138. dahp = 30;
  139. label:
  140. int atkq;
  141. cout << "DON ANSTEL (ANSTEL) APPEARS" << endl;
  142. cout << endl;
  143. cout << "STATS:"<< endl;
  144. cout << "hp: " << hp << endl;
  145. cout << "ehp: " << dahp << endl;
  146. cout << endl;
  147. cout << "ATTACKS:" << endl;
  148. cout << "(1) sword attack" << endl;
  149. cout <<"(2) rain of arrows" << endl;
  150. cout << "(3) dark ritual" << endl;
  151. cout << "(4) summon healer" << endl;
  152. cout << "(5) escape" << endl;
  153. cin >> atkq;
  154. if (atkq == 1){
  155. cout << "You attack ANSTEL with your sword" << endl;
  156. dahp -= rand()%5;
  157. cout << "ANSTEL STABS YOU WITH HIS KNIFE" << endl;
  158. hp -= rand()% 5;
  159. if (dahp <= 0){
  160. win();
  161.  
  162. score += 100;
  163. game();
  164. }
  165. if (hp <= 0){
  166. lose();
  167. }
  168. }
  169. if (atkq == 2){
  170. cout << "you activated arrow rain "<< endl;
  171. dahp -= rand()%10;
  172. hp-= rand()%5;
  173. cout << "ANSTEN heals" << endl;
  174. rhp += rand()%5;
  175. if (dahp <= 0){
  176. win();
  177.  
  178. score += 100;
  179. game();
  180. }
  181. if (hp <= 0){
  182. lose();
  183. }
  184. }
  185. if (atkq == 3){
  186. cout << "you did a dark ritual" << endl;
  187. if (rand()% 10 >= 3){
  188. dahp -= rand()%20;
  189. } else {
  190. cout << "It did not work" << endl;
  191. }
  192. cout << "ANSTEN SHOOTS YOU WITH HIS TOMMY GUN " << endl;
  193. hp -= rand()% 10;
  194. if (dahp <= 0){
  195. win();
  196.  
  197. score += 100;
  198. game();
  199. }
  200. if (hp <= 0){
  201. lose();
  202. }
  203. }
  204. if (atkq == 4){
  205. cout << "you healed" << endl;
  206. hp += rand()% 15;
  207. cout << "ANSTEN SHOOTS YOU WITH HIS REVOLVER" << endl;
  208. hp -= rand()% 7;
  209. if (dahp <= 0){
  210. win();
  211.  
  212. score += 100;
  213. game();
  214. }
  215. if (hp <= 0){
  216. lose();
  217. }
  218. }
  219. if (atkq == 5){
  220. if (rand()% 10 >= 5){
  221. esc();
  222. game();
  223.  
  224. }
  225. cout << "YOU DID NOT ESCAPE" << endl;
  226. cout << " ANSTEN HEALS" << endl;
  227. dahp += rand()% 15;
  228. }
  229. goto label;
  230. }
  231. void SPYMASTER (void)
  232. {
  233. smhp = 35;
  234. label:
  235.  
  236. int atkw;
  237. cout << "SPY MASTER (SPY) APPEARS" << endl;
  238. cout << endl;
  239. cout << "STATS:"<< endl;
  240. cout << "hp: " << hp << endl;
  241. cout << "ehp: " << smhp << endl;
  242. cout << endl;
  243. cout << "ATTACKS:" << endl;
  244. cout << "(1) sword attack" << endl;
  245. cout <<"(2) rain of arrows" << endl;
  246. cout << "(3) dark ritual" << endl;
  247. cout << "(4) summon healer" << endl;
  248. cout << "(5) escape" << endl;
  249. cin >> atkw;
  250. if (atkw == 1){
  251. cout << "You attack SPY with your sword" << endl;
  252. smhp -= rand()%5;
  253. cout << "SPY shoots you" << endl;
  254. hp -= rand()% 5;
  255. if (smhp <= 0){
  256. win();
  257.  
  258. score += 200;
  259. game();
  260. }
  261. if (hp <= 0){
  262. lose();
  263. }
  264. }
  265. if (atkw == 2){
  266. cout << "you activated arrow rain "<< endl;
  267. smhp -= rand()%10;
  268. hp-= rand()%5;
  269. cout << "SPY heals" << endl;
  270. smhp += rand()%5;
  271. if (smhp <= 0){
  272. win();
  273.  
  274. score += 200;
  275. game();
  276. }
  277. if (hp <= 0){
  278. lose();
  279. }
  280. }
  281. if (atkw == 3){
  282. cout << "you did a dark ritual" << endl;
  283. if (rand()% 10 >= 3){
  284. smhp -= rand()%20;
  285. } else {
  286. cout << "It did not work" << endl;
  287. }
  288. cout << "SPY SHOOTS YOU " << endl;
  289. hp -= rand()% 10;
  290. if (smhp <= 0){
  291. win();
  292.  
  293. score += 200;
  294. game();
  295. }
  296. if (hp <= 0){
  297. lose();
  298. }
  299. }
  300. if (atkw == 4){
  301. cout << "you healed" << endl;
  302. hp += rand()% 15;
  303. cout << "SPY SHOOTS YOU" << endl;
  304. hp -= rand()% 7;
  305. if (smhp <= 0){
  306. win();
  307.  
  308. score += 200;
  309. game();
  310. }
  311. if (hp <= 0){
  312. lose();
  313. }
  314. }
  315. if (atkw == 5){
  316. if (rand()% 10 >= 5){
  317. esc();
  318. game();
  319. }
  320. cout << "YOU DID NOT ESCAPE" << endl;
  321. cout << "SPY HEALS" << endl;
  322. smhp += rand()% 15;
  323. }
  324. goto label;
  325. }
  326. void OVERLORD(void)
  327. {
  328. ohp = 45;
  329. label:
  330. int atke;
  331. cout << "OVERLORD ATTACKS!" << endl;
  332. cout << endl;
  333. cout << "STATS:"<< endl;
  334. cout << "hp: " << hp << endl;
  335. cout << "ehp: " << ohp << endl;
  336. cout << endl;
  337. cout << "ATTACKS:" << endl;
  338. cout << "(1) sword attack" << endl;
  339. cout <<"(2) rain of arrows" << endl;
  340. cout << "(3) dark ritual" << endl;
  341. cout << "(4) summon healer" << endl;
  342. cout << "(5) escape" << endl;
  343. cin >> atke;
  344. if (atke == 1){
  345. cout << "You attack OVERLORD with your sword" << endl;
  346. ohp -= rand()%5;
  347. cout << "OVERLORD THROWS YOU" << endl;
  348. hp -= rand()% 5;
  349. if (ohp <= 0){
  350. win();
  351. score += 400;
  352. game();
  353. }
  354. if (hp <= 0){
  355. lose();
  356. }
  357. }
  358. if (atke == 2){
  359. cout << "you activated arrow rain "<< endl;
  360. ohp -= rand()%10;
  361. hp-= rand()%5;
  362. cout << "OVERLORD heals" << endl;
  363. ohp += rand()%5;
  364. if (ohp <= 0){
  365. win();
  366.  
  367. score += 400;
  368. game();
  369. }
  370. if (hp <= 0){
  371. lose();
  372. }
  373. }
  374. if (atke == 3){
  375. cout << "you did a dark ritual" << endl;
  376. if (rand()% 10 >= 3){
  377. ohp -= rand()%20;
  378. } else {
  379. cout << "It did not work" << endl;
  380. }
  381. cout << "OVERLORD throws fireballs " << endl;
  382. hp -= rand()% 10;
  383. if (ohp <= 0){
  384. win();
  385.  
  386. score += 400;
  387. game();
  388. }
  389. if (hp <= 0){
  390. lose();
  391. }
  392. }
  393. if (atke == 4){
  394. cout << "you healed" << endl;
  395. hp += rand()% 15;
  396. cout << "OVERLORD BOMBARDS YOU" << endl;
  397. hp -= rand()% 7;
  398. if (ohp <= 0){
  399. win();
  400.  
  401. score += 400;
  402. game();
  403. }
  404. if (hp <= 0){
  405. lose();
  406. }
  407. }
  408. if (atke == 5){
  409. if (rand()% 10 >= 5){
  410. esc();
  411.  
  412. score += 400;
  413. game();
  414. }
  415. cout << "YOU DID NOT ESCAPE" << endl;
  416. cout << "OVERLORD HEALS" << endl;
  417. ohp += rand()% 15;
  418. }
  419. if (ohp <= 0){
  420. win();
  421.  
  422. score += 400;
  423. game();
  424. }
  425. if (hp <= 0){
  426. lose();
  427. }
  428. goto label;
  429. }
  430. void DRAGONLORD(void)
  431. {
  432. dlhp = 50;
  433. label:
  434.  
  435. int atkr;
  436. cout << "DRAGONLORD (DRAGON) ATTACKS!" << endl;
  437. cout << endl;
  438. cout << "STATS:"<< endl;
  439. cout << "hp: " << hp << endl;
  440. cout << "ehp: " << dlhp << endl;
  441. cout << endl;
  442. cout << "ATTACKS:" << endl;
  443. cout << "(1) sword attack" << endl;
  444. cout <<"(2) rain of arrows" << endl;
  445. cout << "(3) dark ritual" << endl;
  446. cout << "(4) summon healer" << endl;
  447. cout << "(5) escape" << endl;
  448. cin >> atkr;
  449. if (atkr == 1){
  450. cout << "You attack DRAGON with your sword" << endl;
  451. dlhp -= rand()%5;
  452. cout << "DRAGON THROWS YOU" << endl;
  453. hp -= rand()% 5;
  454. if (dlhp <= 0){
  455. win();
  456.  
  457. score += 1000;
  458. game();
  459. }
  460. if (hp <= 0){
  461. lose();
  462. }
  463. }
  464. if (atkr == 2){
  465. cout << "you activated arrow rain "<< endl;
  466. dlhp -= rand()%10;
  467. hp-= rand()%5;
  468. cout << "DRAGON heals" << endl;
  469. dlhp += rand()%5;
  470. if (dlhp <= 0){
  471. win();
  472.  
  473. score += 1000;
  474. game();
  475. }
  476. if (hp <= 0){
  477. lose();
  478. }
  479. }
  480. if (atkr == 3){
  481. cout << "you did a dark ritual" << endl;
  482. if (rand()% 10 >= 3){
  483. dlhp -= rand()%20;
  484. } else {
  485. cout << "It did not work" << endl;
  486. }
  487. cout << "DRAGON throws fireballs " << endl;
  488. hp -= rand()% 10;
  489. if (dlhp <= 0){
  490. win();
  491.  
  492. score += 1000;
  493. game();
  494. }
  495. if (hp <= 0){
  496. lose();
  497. }
  498. }
  499. if (atkr == 4){
  500. cout << "you healed" << endl;
  501. hp += rand()% 15;
  502. cout << "DRAGON BOMBARDS YOU" << endl;
  503. hp -= rand()% 7;
  504. if (dlhp <= 0){
  505. win();
  506.  
  507. score += 1000;
  508. game();
  509. }
  510. if (hp <= 0){
  511. lose();
  512. }
  513. }
  514. if (atkr == 5){
  515. if (rand()% 10 >= 5){
  516. esc();
  517. game();
  518. }
  519. cout << "YOU DID NOT ESCAPE" << endl;
  520. cout << "DRAGON HEALS" << endl;
  521. dlhp += rand()% 15;
  522. }
  523. if (dlhp <= 0){
  524. win();
  525.  
  526. score += 1000;
  527. game();
  528. }
  529. if (hp <= 0){
  530. lose();
  531. }
  532. goto label;
  533. }
  534. void game(void)
  535. {
  536. srand(time(0));
  537. label:
  538. char conf;
  539. int e;
  540. int ev = rand()%10;
  541. cout << "YOUR ADVENTURE BEGINS..." << endl;
  542. cout << "heal: 1" << endl;
  543. cout << "quit: 2" << endl;
  544. cout << "hp: " << hp << endl;
  545. cout << "score: " << score << endl;
  546. cin >> e;
  547. if ( e == 1){
  548. cout << "heal" << endl;
  549. hp += rand()%25;
  550. }
  551. if (e == 2){
  552. cout << "are you sure? (Y/y) for yes, (N/n) for no" << endl;
  553. cin >> conf;
  554. switch (conf){
  555. case 'N':
  556. case 'n':
  557. goto label;
  558. break;
  559. case 'Y':
  560. case 'y':
  561. main();
  562. break;
  563. }
  564. }
  565. if (score == 10000){
  566. truewin();
  567. }
  568.  
  569. switch (ev){
  570. case 1:
  571. ROTSALA();
  572. break;
  573. case 2:
  574. DON();
  575. break;
  576. case 3:
  577. SPYMASTER();
  578. break;
  579. case 4:
  580. OVERLORD();
  581. break;
  582. case 5:
  583. DRAGONLORD();
  584. break;
  585. default:
  586. cout << "you walk through an empty feild..." << endl;
  587. break;
  588. }
  589.  
  590. goto label;
  591. }
  592. void credits(void)
  593. {
  594. cout << "developer /programmer : ALFRED NATHANIEL M. DIANA" << endl;
  595. sleep(1);
  596. cout << "Mother: Anstacia Abayan Melquiades Diana" << endl;
  597. cout << "Father: Alfredo Servillon Diana" << endl;
  598. sleep(1);
  599. cout << "Thank you for playing" << endl;
  600. sleep(1);
  601. }
  602. int main()
  603. {
  604. int dec;
  605. label:
  606. cout << "RPG CLASSIC" << endl;
  607. cout << "(1) GAME , (2) CREDITS" << endl;
  608. cin >> dec;
  609. switch (dec){
  610. case 1:
  611. game();
  612. break;
  613. case 2:
  614. credits();
  615. break;
  616. default :
  617. cout << "ERROR! NOT VALID NUMBER!" << endl;
  618. break;
  619.  
  620.  
  621. }
  622. goto label;
  623. }
Add Comment
Please, Sign In to add comment