Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- int main()
- {
- srand ( time(NULL) );
- int Stat[3] = {0,0,0}; // HP, Attack, Defense.
- int HP, maxHP, mHP, level, race, tmp; // Yours and the enemys current HP, and the stage
- char Name[20];
- printf("RPG Survival, welcome!\n");
- printf("What's your name?: "); scanf("%s", Name);
- printf("\nChoose your race, along with it comes stats, in order HP-Attack-Defense:\n");
- printf("1. Human; 10-10-10\n");
- printf("2. Orc; 10-13-7\n");
- printf("3. Elf; 15-7-8\n");
- printf("4. Wizard; 6-11-12\n");
- printf("Type the number for the race of your choice: "); scanf("%d", &race);
- switch(race)
- {
- case 1:
- Stat[0] = 10;
- Stat[1] = 10;
- Stat[2] = 10;
- break;
- case 2:
- Stat[0] = 10;
- Stat[1] = 13;
- Stat[2] = 17;
- break;
- case 3:
- Stat[0] = 15;
- Stat[1] = 7;
- Stat[2] = 8;
- break;
- case 4:
- Stat[0] = 6;
- Stat[1] = 11;
- Stat[2] = 12;
- break;
- }
- maxHP = Stat[0]*1.5;
- HP = maxHP;
- printf("\nTime to start your journey!\n\n");
- while(HP>0)
- {
- int Pow, npow, choice, mchoice, mmaxHP;
- printf("You encounter a level %d enemy!\n", level);
- mHP = level*5+1;
- mmaxHP = level*5+1;
- while(mHP>0)
- {
- printf("You have %d health out of %d\n", HP, maxHP);
- printf("The monster has %d health left.\n", mHP);
- printf("What would you like to do?\n1. Attack \n2. Defend\n3. Heal\n> ");
- scanf("%d", &choice);
- mchoice = rand()%2+1;
- if(mchoice==1){printf("The monster defended itself!\n");}
- switch(choice)
- {
- case 1: // Attack
- Pow = rand() % 5 + Stat[1];
- switch(mchoice)
- {
- case 2: // Blocked!
- npow = Pow-10;
- if(npow<0) npow = 0;
- printf("%s attacked the monster! It did %d damage!\n", Name, npow);
- mHP -= npow;
- break;
- default:
- printf("%s attacked the monster! it did %d damage!\n", Name, Pow);
- mHP -= Pow;
- }
- break;
- case 2: // Defend
- printf("%s is defending!\n", Name);
- break;
- case 3: // Healing
- Pow = rand()%5 + Stat[2];
- if(HP+Pow > maxHP)
- {
- printf("%s healed to full health\n", Name);
- HP = maxHP;
- }
- else if(HP+Pow < maxHP)
- {
- printf("%s healed %d points!\n", Name, Pow);
- HP += Pow;
- }
- }
- if(mHP<=0)
- {
- printf("The monster died!\n\n");
- goto SKIP;
- }
- switch(mchoice)
- {
- case 1: // Attack
- Pow = rand()%5 + level;
- switch(choice)
- {
- case 2: // Blocked!
- npow = Pow-10;
- if(npow<0) npow = 0;
- printf("The monster attacked you! It did %d damage!\n", npow);
- HP -= npow;
- break;
- default:
- printf("The monster attacked you! it did %d damage!\n", Pow);
- HP -= Pow;
- }
- break;
- case 3: // Healing
- Pow = rand()%5+(level*3);
- if(mHP+Pow > mmaxHP)
- {
- printf("The monster healed to full health!\n");
- mHP = mmaxHP;
- }
- else if(mHP+Pow < mmaxHP)
- {
- printf("The monster healed %d points!\n", Pow);
- mHP += Pow;
- }
- }
- if(HP<=0)
- {
- printf("You died!\n\n");
- }
- SKIP:
- printf("\n");
- }
- level = level+1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement