Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Copyright 2002 */
- #include <iostream.h>
- #include <iomanip.h>
- #include <string.h>
- #include <windows.h>
- #include <conio.h>
- #include <time.h>
- //defined functions
- void fightagain();
- void map1();
- void map2();
- void map3();
- void fork();
- void fight1();
- void fight2();
- void keepgoing();
- void goback();
- //defined variables
- int east=0; //keeps track if you have gone east
- int west=0; //keeps track if you have gone east
- int race; //character race
- int gender; //character gender
- int playerclass; //character class
- int life=3; //lives
- int choice1;//first choice you make
- int dir2; //second choice (which direction)
- int dir3; //third choice (which direction)
- int choice4; //fourth choice (fight again or run away)
- int hp=100; //character health
- int trollhp=75; //troll's health
- int youdamage; //damage you do
- int theirdamage; //damage monster does
- int training=0; //if you have trained or not
- //strings
- char lost1; //holds y or n to go back or not
- char name[20]; //holds character name
- int main() {
- cout<<" **************************************************"<<endl;
- cout<<" WILL'S RPG "<<endl;
- cout<<" **************************************************"<<endl;
- cout<<" "<<endl;
- cout<<" "<<endl;
- cout<<" "<<endl;
- cout<<" "<<endl;
- cout<<"Welcome to Will's RPG. You have been bestowed a powerful gift from a friendly"<<endl;
- cout<<"sorceror named Granthar that was in hiding. This gift is a very evil ring."<<endl;
- cout<<"He told you that this ring must be destroyed. The only way to do that is to"<<endl;
- cout<<"find a powerful wizard named Azgor. He is the only one that can destroy the"<<endl;
- cout<<"ring so it can be saved from evil forces that would abuse its power. Getting"<<endl;
- cout<<"to Azgor will be a very hard challenge because he lives on the other side of a"<<endl;
- cout<<"very deadly forest that you must pass through. Granthar has grown very weak so"<<endl;
- cout<<"he must trust in you with the ring. You have only 3 lives to make it through"<<endl;
- cout<<"the forest. "<<endl;
- cout<<" "<<endl;
- cout<<"Press any key to continue . . ."<<endl;
- getch();
- system("cls"); //clears screen
- cout<<"What is the gender of your character?"<<endl;
- cout<<"1. Male\n";
- cout<<"2. Female\n";
- cin>>gender;
- system("cls");
- cout<<"What race would you like to be?"<<endl;
- cout<<"1. Human"<<endl;
- cout<<"2. Goblin"<<endl;
- cout<<"3. Dwarf"<<endl;
- cout<<"4. Orc "<<endl;
- cin>>race;
- system("cls");
- cout<<"What class would you like to be?"<<endl;
- cout<<"1. A stealthy assassin armed with your trusty dagger"<<endl;
- cout<<"2. A holy paladin armed with a sword and shield"<<endl;
- cout<<"3. A strong barbarian armed with your long sword"<<endl;
- cout<<"4. A wise spellcaster armed with your magical staff"<<endl;
- cin>>playerclass;
- system("cls");
- cout<<"Enter your character's name: ";
- cin>>name;
- system("cls");
- while (life>0) {
- if(life==3) {
- system("cls");
- cout<<"You have 3 lives left."<<endl;
- cout<<"You are in your small house with the ring in your pocket and your"<<endl;
- if (playerclass==1)
- {
- cout<<"dagger in your hand."<<endl;
- }
- if (playerclass==2)
- {
- cout<<"sword in one hand and shield in the other."<<endl;
- }
- if (playerclass==3)
- {
- cout<<"long sword in your hands."<<endl;
- }
- if (playerclass==4)
- {
- cout<<"magical staff in your hands."<<endl;
- }
- cout<<"You know your quest and you must make it to the other side of the"<<endl;
- cout<<"woods as quickly as possible."<<endl;
- cout<<"Press any key to continue . . ."<<endl;
- getch();
- system("cls");
- cout<<"You enter the woods with an eerie sense that there is much danger in"<<endl;
- cout<<"here. You had better be careful. You start on the path working your way"<<endl;
- cout<<"north."<<endl;
- cout<<"Press any key to continue . . ."<<endl;
- getch();
- system("cls");
- cout<<"These woods are very dark and seem odd. You look at your map and can't"<<endl;
- cout<<"tell if this is where you are supposed to be. It might just be because you"<<endl;
- cout<<"have never been this far in before."<<endl;
- cout<<"Would you like to keep on going? (Y or N)"<<endl;
- cin>>lost1;
- switch(lost1)
- {
- case 'y':
- case 'Y': keepgoing();
- break;
- case 'n':
- case 'N': goback();
- break;
- default:
- cout<<"I said to enter Y or N, not "<<lost1<<"."<<endl;
- life=0;
- }//end switch
- }//end if
- if(life==2) {
- system("cls");
- cout<<"You have 2 lives left."<<endl;
- cout<<"You awake in your small house with the ring in your pocket and your"<<endl;
- if (playerclass==1)
- {
- cout<<"dagger in your hand."<<endl;
- }
- if (playerclass==2)
- {
- cout<<"sword in one hand and shield in the other."<<endl;
- }
- if (playerclass==3)
- {
- cout<<"long sword in your hands."<<endl;
- }
- if (playerclass==4)
- {
- cout<<"magical staff in your hands."<<endl;
- }
- cout<<"You know your quest and you must make it to the other side of the"<<endl;
- cout<<"woods as quickly as possible."<<endl;
- cout<<"Press any key to continue . . ."<<endl;
- getch();
- system("cls");
- cout<<"You enter the woods with an eerie sense that there is much danger in"<<endl;
- cout<<"here. You had better be careful. You start on the path working your way"<<endl;
- cout<<"north."<<endl;
- cout<<"Press any key to continue . . ."<<endl;
- getch();
- system("cls");
- cout<<"These woods are very dark and seem odd. You look at your map and can't"<<endl;
- cout<<"tell if this is where you are supposed to be. It might just be because you"<<endl;
- cout<<"have never been this far in before."<<endl;
- cout<<"Would you like to keep on going? (Y or N)"<<endl;
- cin>>lost1;
- switch(lost1)
- {
- case 'y':
- case 'Y': keepgoing();
- break;
- case 'n':
- case 'N': goback();
- break;
- default:
- cout<<"I said to enter Y or N, not "<<lost1<<"."<<endl;
- life=0;
- }//end switch
- }//end if
- if(life==1) {
- system("cls");
- cout<<"You have 1 life left."<<endl;
- cout<<"You awake in your small house with the ring in your pocket and your"<<endl;
- if (playerclass==1)
- {
- cout<<"dagger in your hand."<<endl;
- }
- if (playerclass==2)
- {
- cout<<"sword in one hand and shield in the other."<<endl;
- }
- if (playerclass==3)
- {
- cout<<"long sword in your hands."<<endl;
- }
- if (playerclass==4)
- {
- cout<<"magical staff in your hands."<<endl;
- }
- cout<<"You know your quest and you must make it to the other side of the"<<endl;
- cout<<"woods as quickly as possible."<<endl;
- cout<<"Press any key to continue . . ."<<endl;
- getch();
- system("cls");
- cout<<"You enter the woods with an eerie sense that there is much danger in"<<endl;
- cout<<"here. You had better be careful. You start on the path working your way"<<endl;
- cout<<"north."<<endl;
- cout<<"Press any key to continue . . ."<<endl;
- getch();
- system("cls");
- cout<<"These woods are very dark and seem odd. You look at your map and can't"<<endl;
- cout<<"tell if this is where you are supposed to be. It might just be because you"<<endl;
- cout<<"have never been this far in before."<<endl;
- cout<<"Would you like to keep on going? (Y or N)"<<endl;
- cin>>lost1;
- switch(lost1)
- {
- case 'y':
- case 'Y': keepgoing();
- break;
- case 'n':
- case 'N': goback();
- break;
- default:
- cout<<"I said to enter Y or N, not "<<lost1<<"."<<endl;
- life=0;
- }//end switch
- }//end if
- }//end while
- cout<<"You have run out of lives. GAME OVER."<<endl;
- cout<<"Please try again."<<endl;
- getch();
- return 0;
- }//end program
- //\\\\\\\\\\\\\\\\\\
- // FUNCTIONS >>
- ////////////////////
- //==================================================================
- //\\\\\\\\\\\\\\\\\\
- // CHOICE 1 >>
- ////////////////////
- //one of these 2 functions are called when you press y or n at the first choice
- //*******************************************************************
- void keepgoing() {
- system("cls");
- cout<<"You decide to keep on moving forward. Suddenly you feel a snake twist around"<<endl;
- cout<<"you. It is a huge snake and its thick body has rendered you motionless."<<endl;
- cout<<"It wraps tighter and tighter as your breath lessens. Everything goes black."<<endl;
- cout<<"You have lost a life."<<endl;
- cout<<"Press any key to continue . . ."<<endl;
- getch();
- system("cls");
- life = life - 1;
- }
- void goback() {
- system("cls");
- cout<<"You decide to go back and retrace your steps. You journey back and can see"<<endl;
- cout<<"your home in the distance. As you turn and face the woods again you realize"<<endl;
- cout<<"you had taken the wrong path. You start on the correct path wondering where"<<endl;
- cout<<"the other trail would have led."<<endl;
- cout<<"Press any key to continue . . ."<<endl;
- getch();
- system("cls");
- fork();
- }
- //*******************************************************************
- //\\\\\\\\\\\\\\\\\\
- // FIGHT >>
- ////////////////////
- //this is the intro to the fight, only called once
- //*******************************************************************
- void fight1() {
- cout<<"As you turn around you are met with a 10 foot tall, green skinned troll. He"<<endl;
- cout<<"towers above you holding a huge wooden club in his hand and looks ready to"<<endl;
- cout<<"fight with you. You draw your weapon but have a decision to make."<<endl<<endl;
- cout<<"You have "<<hp<<" health left."<<endl;
- cout<<"The troll has "<<trollhp<<" health left."<<endl<<endl;
- cout<<"What do you do?"<<endl;
- cout<<"1. Attack the troll"<<endl;
- cout<<"2. Run away"<<endl;
- cin>>dir3;
- if (dir3==1)
- {
- system("cls");
- srand( (unsigned)time( NULL ) );
- if (training==1)
- {
- youdamage = rand() % 35;
- cout << "You attack the troll for " << youdamage << " points of damage"<<endl;
- trollhp = trollhp - youdamage;
- }
- if (training==0)
- {
- youdamage = rand() % 20;
- cout << "You attack the troll for " << youdamage << " points of damage"<<endl;
- trollhp = trollhp - youdamage;
- }
- theirdamage = rand() % 15;
- cout << "The troll attacks you for " << theirdamage << " points of damage"<<endl;
- hp = hp - theirdamage;
- cout<<" "<<endl;
- cout<<"You have "<<hp<<" health left."<<endl;
- cout<<"The troll has "<<trollhp<<" health left."<<endl<<endl;
- getch();
- fightagain();
- }
- if (dir3==2) {
- system("cls");
- cout<<"You turn around and begin to run but are too slow. The troll catches up to you"<<endl;
- cout<<"and you feel an enormous pain in your torso as his club smacks against you."<<endl;
- cout<<"Your body crumples to the ground."<<endl;
- cout<<"Press any key to continue . . ."<<endl;
- getch();
- system("cls");
- life = life-1; //subtracts 1 life
- }
- }//end of function
- //this is the end of first attack
- //*******************************************************************
- //\\\\\\\\\\\\\\\\\\
- // FIGHTAGAIN >>
- ////////////////////
- //this function is for the 2nd time and beyond for fighting the troll
- //*******************************************************************
- void fightagain() {
- if (hp<=0)
- {
- hp=0;
- system("cls");
- cout <<"The troll hits you and everything goes black as your body falls to the ground."<<endl;
- cout <<"Press any key to continue . . ."<<endl;
- getch();
- system("cls");
- life=life-1;
- main();
- }
- if (trollhp<=0)
- {
- trollhp=0;
- system("cls");
- cout << "The troll falls to the ground dead and you claim your first victory."<<endl;
- cout <<"You head back to the fork with new pride."<<endl;
- cout <<"Press any key . . ."<<endl;
- west=1;
- getch();
- system("cls");
- fork();
- }
- cout<<"What do you do?"<<endl;
- cout<<"1. Attack the troll"<<endl;
- cout<<"2. Run away"<<endl;
- cin>>choice4;
- if (choice4==1)
- {
- system("cls");
- srand( (unsigned)time( NULL ) );
- if (training==1)
- {
- youdamage = rand() % 30;
- cout << "You attack the troll for " << youdamage << " points of damage"<<endl;
- trollhp = trollhp - youdamage;
- }
- if (training==0)
- {
- youdamage = rand() % 20;
- cout << "You attack the troll for " << youdamage << " points of damage"<<endl;
- trollhp = trollhp - youdamage;
- }
- if (trollhp<=0)
- {
- trollhp=0;
- }
- theirdamage = rand() % 15;
- cout << "The troll attacks you for " << theirdamage << " points of damage"<<endl;
- hp = hp - theirdamage;
- cout<<" "<<endl;
- cout<<"You have "<<hp<<" health left."<<endl;
- cout<<"The troll has "<<trollhp<<" health left."<<endl<<endl;
- getch();
- fightagain();
- }
- //this is the function if you run away from fightagain
- if (choice4==2) {
- system("cls");
- cout<<"You turn around and begin to run but are too slow. The troll catches up to you"<<endl;
- cout<<"and you feel an enormous pain in your torso as his club smacks against you."<<endl;
- cout<<"Your body crumples to the ground."<<endl;
- cout<<"Press any key to continue . . ."<<endl;
- getch();
- system("cls");
- life = life-1; //subtracts 1 life
- }
- } //end function
- //*******************************************************************
- //\\\\\\\\\\\\\\\\\\
- // FORK >>
- ////////////////////
- //*******************************************************************
- void fork() {
- //if character hasn't been east and west yet
- if(east + west < 2) {
- cout<<"At a fork, the path splits into 2 ways."<<endl;
- cout<<"Which direction will you go?"<<endl;
- cout<<"1. East"<<endl;
- cout<<"2. West"<<endl;
- cin>>choice1;
- }
- //if the character has been east and west
- if(east + west ==2) {
- cout<<"At the fork you find a new path that you didn't notice before. It leads north."<<endl;
- cout<<"Which direction will you go?"<<endl;
- cout<<"1. East"<<endl;
- cout<<"2. West"<<endl;
- cout<<"3. North"<<endl;
- cin>>choice1;
- }
- if(choice1==1) {
- system("cls");
- map1();
- }
- if(choice1==2) {
- system("cls");
- map2();
- }
- if(choice1==3) {
- system("cls");
- map3();
- }
- }
- //*******************************************************************
- //\\\\\\\\\\\\\\\\\\
- // MAP1 >>
- ////////////////////
- //go to map1(east)
- //*******************************************************************
- void map1() {
- if (east==1) {
- cout<<"You have already been here. You head back to the fork."<<endl;
- cout<<"Press any key to continue . . ."<<endl;
- getch();
- system("cls");
- fork();
- }
- if (east==0) {
- cout<<"There is the back of a small hut in the clearing of the woods. You wonder"<<endl;
- cout<<"who lives there and have to decide if you want to go see. The woods are"<<endl;
- cout<<"unpredictable."<<endl;
- east=1;
- cout<<"What do you do?"<<endl;
- cout<<"1. Go see who lives there"<<endl;
- cout<<"2. Go back to the fork"<<endl;
- cin>>dir2;
- if (dir2==1) {
- system("cls");
- cout<<"You go investigate and when you come to the front you realize that it is a"<<endl;
- cout<<"a training school. The master welcomes you and you recieve training. You"<<endl;
- cout<<"now are a better fighter. You decide to head back to the fork."<<endl;
- cout<<"Press any key to continue . . ."<<endl;
- training=1;
- getch();
- system("cls");
- fork();
- }
- if (dir2==2) {
- cout<<"You turn around and head back to the fork"<<endl;
- cout<<"Press any key to continue . . ."<<endl;
- getch();
- system("cls");
- fork();
- }
- }//ends if function
- }//ends map1
- //*******************************************************************
- //\\\\\\\\\\\\\\\\\\
- // MAP2 >>
- ////////////////////
- //go to map2(west)
- //*******************************************************************
- void map2() {
- if (west==1) {
- cout<<"You have already been here. You head back to the fork."<<endl;
- cout<<"Press any key to continue . . ."<<endl;
- getch();
- system("cls");
- fork();
- }
- if (west==0) {
- cout<<"You look around and see absolutely nothing but thick trees. You turn around"<<endl;
- cout<<"to go back to the fork."<<endl;
- cout<<"Press any key to continue . . ."<<endl;
- getch();
- system("cls");
- fight1();
- }
- }//end map2
- //*******************************************************************
- //\\\\\\\\\\\\\\\\\\
- // MAP3 >>
- ////////////////////
- //go to map3(north)
- //*******************************************************************
- void map3() {
- cout<<"As you march on the trail north you see the end of the trail and the fields"<<endl;
- cout<<"beyond. You rush towards the exit of the forest."<<endl;
- cout<<"Press any key to continue . . . "<<endl;
- getch();
- system("cls");
- fight2(); //go to fight 2
- }
- //havent completed
- void fight2() {
- cout<<"You win because I'm to lazy to put in another fight."<<endl;
- getch();
- system("cls");
- main();
- }
- //*******************************************************************
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement