Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.30 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. int main()
  6. {
  7.     srand ( time(NULL) );
  8.     int Stat[3] = {0,0,0}; // HP, Attack, Defense.
  9.     int HP, maxHP, mHP, level, race, tmp; // Yours and the enemys current HP, and the stage
  10.     char Name[20];
  11.     printf("RPG Survival, welcome!\n");
  12.     printf("What's your name?: "); scanf("%s", Name);
  13.     printf("\nChoose your race, along with it comes stats, in order HP-Attack-Defense:\n");
  14.     printf("1. Human; 10-10-10\n");
  15.     printf("2. Orc; 10-13-7\n");
  16.     printf("3. Elf; 15-7-8\n");
  17.     printf("4. Wizard; 6-11-12\n");
  18.     printf("Type the number for the race of your choice: "); scanf("%d", &race);
  19.     switch(race)
  20.     {
  21.         case 1:
  22.         Stat[0] = 10;
  23.         Stat[1] = 10;
  24.         Stat[2] = 10;
  25.         break;
  26.  
  27.         case 2:
  28.         Stat[0] = 10;
  29.         Stat[1] = 13;
  30.         Stat[2] = 17;
  31.         break;
  32.  
  33.         case 3:
  34.         Stat[0] = 15;
  35.         Stat[1] = 7;
  36.         Stat[2] = 8;
  37.         break;
  38.  
  39.         case 4:
  40.         Stat[0] = 6;
  41.         Stat[1] = 11;
  42.         Stat[2] = 12;
  43.         break;
  44.     }
  45.     maxHP = Stat[0]*1.5;
  46.     HP = maxHP;
  47.     printf("\nTime to start your journey!\n\n");
  48.     while(HP>0)
  49.     {
  50.         int Pow, npow, choice, mchoice, mmaxHP;
  51.         printf("You encounter a level %d enemy!\n", level);
  52.         mHP = level*5+1;
  53.         mmaxHP = level*5+1;
  54.         while(mHP>0)
  55.         {
  56.             printf("You have %d health out of %d\n", HP, maxHP);
  57.             printf("The monster has %d health left.\n", mHP);
  58.             printf("What would you like to do?\n1. Attack \n2. Defend\n3. Heal\n> ");
  59.             scanf("%d", &choice);
  60.             mchoice = rand()%2+1;
  61.             if(mchoice==1){printf("The monster defended itself!\n");}
  62.             switch(choice)
  63.             {
  64.                 case 1: // Attack
  65.                 Pow = rand() % 5 + Stat[1];
  66.                 switch(mchoice)
  67.                 {
  68.                     case 2: // Blocked!
  69.                     npow = Pow-10;
  70.                     if(npow<0) npow = 0;
  71.                     printf("%s attacked the monster! It did %d damage!\n", Name, npow);
  72.                     mHP -= npow;
  73.                     break;
  74.  
  75.                     default:
  76.                     printf("%s attacked the monster! it did %d damage!\n", Name, Pow);
  77.                     mHP -= Pow;
  78.                 }
  79.                 break;
  80.  
  81.                 case 2: // Defend
  82.                 printf("%s is defending!\n", Name);
  83.                 break;
  84.  
  85.                 case 3: // Healing
  86.                 Pow = rand()%5 + Stat[2];
  87.                 if(HP+Pow > maxHP)
  88.                 {
  89.                     printf("%s healed to full health\n", Name);
  90.                     HP = maxHP;
  91.                 }
  92.                 else if(HP+Pow < maxHP)
  93.                 {
  94.                     printf("%s healed %d points!\n", Name, Pow);
  95.                     HP += Pow;
  96.                 }
  97.             }
  98.  
  99.             if(mHP<=0)
  100.             {
  101.                 printf("The monster died!\n\n");
  102.                 goto SKIP;
  103.             }
  104.  
  105.             switch(mchoice)
  106.             {
  107.                 case 1: // Attack
  108.                 Pow = rand()%5 + level;
  109.                 switch(choice)
  110.                 {
  111.                     case 2: // Blocked!
  112.                     npow = Pow-10;
  113.                     if(npow<0) npow = 0;
  114.                     printf("The monster attacked you! It did %d damage!\n", npow);
  115.                     HP -= npow;
  116.                     break;
  117.  
  118.                     default:
  119.                     printf("The monster attacked you! it did %d damage!\n", Pow);
  120.                     HP -= Pow;
  121.                 }
  122.                 break;
  123.  
  124.                 case 3: // Healing
  125.                 Pow = rand()%5+(level*3);
  126.                 if(mHP+Pow > mmaxHP)
  127.                 {
  128.                     printf("The monster healed to full health!\n");
  129.                     mHP = mmaxHP;
  130.                 }
  131.                 else if(mHP+Pow < mmaxHP)
  132.                 {
  133.                     printf("The monster healed %d points!\n", Pow);
  134.                     mHP += Pow;
  135.                 }
  136.             }
  137.             if(HP<=0)
  138.             {
  139.                 printf("You died!\n\n");
  140.             }
  141.             SKIP:
  142.             printf("\n");
  143.         }
  144.         level = level+1;
  145.     }
  146.  
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement