Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <cmath>
- #include <ctime>
- using namespace std;
- int main()
- {
- int eHealth = 100; // initial Enemy Health(based on enemy)
- int pHealth = 100; // initial Player Health
- int eAttack = 0; // Enemy Attack Strength(based on enemy)
- int pAttack = 0; // Player Attack Strength(based on level and items)
- int selection = 0; // Selection Variable for Battle Menu
- int hPower = 0; // Healing power Variable(random number)
- int eSelection = 0; // Enemies battle menu selection variable
- int counter = 0; // Counter to establish whos turn it is
- int itemSelect = 0; // Item inventory selection
- int eMagic = 50; // Enemies magic meter
- int pMagic = 50; // Players magic meter
- num1
- num2
- int attackselect = 0;
- cout << "Health: "; // Player name
- cout << pHealth << " " << eHealth << endl; // player and enemy health levels
- cout << "Mana: "; // Player's Magic
- cout << pMagic << " " << eMagic << endl; // player and enemy magic levels
- cout << endl;
- cout << endl;
- cout << "1.Basic Attack" << endl; // lines 31-33 are the battle menu appears
- // frequently throught game
- cout << "2.Special Attack" << endl;
- cout << "3.Item" << endl;
- do // start of post test loop that runs the game until somebody is dead
- {
- if (counter == 0) // if the counter variable is 0 it is the players turn
- {
- cin >> selection;
- srand(static_cast<int>(time(0))); // randomize all the random variables
- switch (selection)
- {
- case 1: // player chooses to Basic Attack
- pAttack = 1 + rand() % (35 - 1 + 1); // attack power can be between 1-35
- cout << "Basic Attack" << pAttack << endl;
- eHealth = eHealth - pAttack;
- cout << pHealth << " " << eHealth << endl;
- cout << pMagic << " " << eMagic << endl;
- cout << endl;
- cout << endl;
- cout << "1.Basic Attack" << endl;
- cout << "2.Special Attack" << endl;
- cout << "3.Item" << endl;
- break;
- case 2: // if player chooses to use special attack system
- cout << "Attack WEAPONS" << endl;
- cout << "1. Forks - 15 TO 20 HP Damage - 10 MP Used" << endl;
- pAttack = 1 + rand() % (20 - 15 + 15);
- eHealth = eHealth - pAttack;
- pHealth=pHealth+hPower;
- pMagic=pMagic-10;
- cout << endl;
- cout << endl;
- cout << "1.Basic Attack" << endl;
- cout << "2.Special Attack" << endl;
- cout << "3.Item" << endl;
- break;
- cout << "2. Plastic Knives - 20 TO 30 HP Damage - 15 MP Used" << endl;
- pAttack = 1 + rand() % (30 - 20 + 20 );
- eHealth = eHealth - pAttack;
- pHealth=pHealth+hPower;
- pMagic=pMagic-15;
- cout << endl;
- cout << endl;
- cout << "1.Basic Attack" << endl;
- cout << "2.Special Attack" << endl;
- cout << "3.Item" << endl;
- break;
- cout << "3. Bow and Arrows - 10 TO 15 HP Damage - 5 MP Used" << endl;
- pAttack = 1 + rand() % (15 - 10 + 10 );
- eHealth = eHealth - pAttack;
- pHealth=pHealth+hPower;
- pMagic=pMagic-15;
- cout << endl;
- cout << endl;
- cout << "1.Basic Attack" << endl;
- cout << "2.Special Attack" << endl;
- cout << "3.Item" << endl;
- break;
- cout << "4. Axes - 50 HP Damage - 35 MP Used" << endl;
- pAttack = 1 + rand() % (50 - 50 + 50 );
- eHealth = eHealth - pAttack;
- pHealth=pHealth+hPower;
- pMagic=pMagic-35;
- cout << endl;
- cout << endl;
- cout << "1.Basic Attack" << endl;
- cout << "2.Special Attack" << endl;
- cout << "3.Item" << endl;
- break;
- cout << "5. Ice Swords - Freezes oponent for 1 Turn - 30 TO 35 HP Damage - 40 MP Used" << endl;
- pAttack = 1 + rand() % (35 - 30 + 30 );
- eHealth = eHealth - pAttack;
- srand (static_cast <unsigned int>(time(0)));
- num1 = 1 + rand() % 6;
- num2 = 1 + rand() % 12;
- pHealth=pHealth+hPower;
- pMagic=pMagic-40;
- cout << endl;
- cout << endl;
- cout << "1.Basic Attack" << endl;
- cout << "2.Special Attack" << endl;
- cout << "3.Item" << endl;
- break;
- cin >> selection;
- switch (selection)
- {
- case 1:
- eHealth = eHealth - 15;
- cout << pHealth << " " << eHealth << endl;
- cout << pMagic << " " << eMagic << endl;
- cout << endl;
- cout << endl;
- cout << "1.Basic Attack" << endl;
- cout << "2.Special Attack" << endl;
- cout << "3.Item" << endl;
- break;
- case 2:
- break;
- } // endSpecial AttackSwitch
- } // endSelectionSwitch
- counter = 1; // advances the counter to 1 to allow the enemies turn
- } // endif
- eSelection = rand() % 2 + 1;
- switch (eSelection)
- case 3:// if player chooses to use item inventory system
- cout<<"ITEM INVENTORY"<<endl;
- cout<<"1.Gatorade Restores 50 HP"<<endl;
- cout<<"2.Ice Coffee Restores 50 MP"<<endl;
- cout<<"3.Bomb Causes Damage to Player"<<endl;
- cin>>itemSelect;
- switch(itemSelect){
- case 1:
- pHealth=pHealth+50;
- cout<<pHealth<<" "<<eHealth<<endl;
- cout<<pMagic<<" "<<eMagic<<endl;
- cout<<endl;
- cout<<endl;
- cout<<"1.Basic Attack"<<endl;
- cout<<"2.Special Attack"<<endl;
- cout<<"3.Item"<<endl;
- break;
- case 2:
- pMagic=pMagic+50;
- cout<<pHealth<<" "<<eHealth<<endl;
- cout<<pMagic<<" "<<eMagic<<endl;
- cout<<endl;
- cout<<endl;
- cout<<"1.Basic Attack"<<endl;
- cout<<"2.Special Attack"<<endl;
- cout<<"3.Item"<<endl;
- break;
- case 3:
- pHealth=pHealth-10;
- eHealth=eHealth-30;
- cout<<pHealth<<" "<<eHealth<<endl;
- cout<<pMagic<<" "<<eMagic<<endl;
- cout<<endl;
- cout<<endl;
- cout<<"1.Basic Attack"<<endl;
- cout<<"2.Special Attack"<<endl;
- cout<<"3.Item"<<endl;
- break;
- }//endItemSwitch
- }while//endSelectionSwitch
- (counter=1);// advances the counter to 1 to allow the enemies turn
- {//endif
- eSelection=rand() % 2+1;
- switch(eSelection)
- {
- case 1:
- eAttack=1+rand()%(35-1+1);
- cout<<"ENEMY ATTACKED PLAYER FOR "<<eAttack<<endl;
- pHealth=pHealth-eAttack;
- cout<<pHealth<<" "<<eHealth<<endl;
- cout<<pMagic<<" "<<eMagic<<endl;
- cout<<endl;
- cout<<endl;
- cout<<"1.Basic Attack"<<endl;
- cout<<"2.Special Attack"<<endl;
- cout<<"3.Item"<<endl;
- break; case 2:
- if(eMagic>10)
- {
- hPower=1+rand()%(35-1+1);
- cout<<"ENEMY HEALED FOR "<<hPower<<endl;
- eMagic=eMagic-10;
- eHealth=eHealth+hPower;
- cout<<pHealth<<" "<<eHealth<<endl;
- cout<<pMagic<<" "<<eMagic<<endl;
- cout<<endl;
- cout<<endl;
- cout<<"1.Basic Attack"<<endl;
- cout<<"2.Special Attack"<<endl;
- cout<<"3.Item"<<endl;
- }
- break;
- }//endeSelectionSwitch
- counter=0;
- }while(eHealth > 1 && pHealth > 1);//loops while both players life is over 1 ends postest loop when players life or enemies falls below 1
- return 0;
- }
- //Why are Special & Items Conflicting each other?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement