Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * File: main.cpp
- * Author: Logan Laframboise and Sean Bennell
- *
- * Created on February 1, 2016, 5:37 PM
- */
- #include <cstdlib>
- #include <ctime>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string>
- #include <iostream>
- #include <ctime>
- using namespace std;
- int random(int x){
- int num;
- srand(time(NULL));
- num = (rand() % x) + 1;
- return num;
- }//simple random number generator
- int randomRange(int x){
- int num;
- int y = 2*x;
- num = (rand() % y) + x;
- return num;
- }//returns a random number between two numbers.
- int bossMoves(int boss){
- switch(boss){
- case 1://Bistrugg
- int choice;
- choice = rand() % 100;
- if(choice <= 20){
- return(1);
- }
- else if(choice <= 40 && choice >20){
- return(2);
- }
- else if(choice <= 100 && choice > 40){
- return(3);
- }
- case 2://Farnsten
- if(choice <=20){
- return(4);
- }
- else if(choice <= 60 && choice > 20){
- return(5);
- }
- else if(choice <= 100 && choice > 60){
- return(6);
- }
- case 3://Lagrath
- if(choice <= 35){
- return(7);
- }
- else if(choice <= 70 && choice > 35){
- return(8);
- }
- else if(choice <= 100 && choice > 70){
- return(9);
- }
- }
- }//%chance to cast different moves
- void userInterface(int eHealth, int eEnergy, int uHealth, int uEnergy){
- cout << "You have: " << uHealth << " health and " << uEnergy << " energy.\n";
- cout << "Your foe has: " << eHealth << " health and " << eEnergy << " energy.\n";
- }//print user interface.
- bool sleep(int x){
- int wakeChance;
- bool sleep = true;
- wakeChance = random(100);
- if(x == 1){
- if(wakeChance <= 20){
- sleep = false;
- }
- else{
- sleep = true;
- }
- }
- else if(x == 2){
- if(wakeChance <= 30){
- sleep = false;
- }
- else{
- sleep = true;
- }
- }
- else if(x == 3){
- if(wakeChance <= 50){
- sleep = false;
- }
- else{
- sleep = true;
- }
- }
- else{
- sleep = false;
- }
- return(sleep);
- }//enemy sleep//wake
- bool timer(int x){
- bool empower;
- if(x > 0 && x <= 5){
- empower = true;
- }
- else{
- empower = false;
- }
- return(empower);
- }//attack steroid// change to for statement later
- bool hit(int x){
- int chance = random(100);
- switch(x){
- bool rate;
- case 1://punch
- if(chance <= 85){
- rate = true;
- return rate;
- }
- case 2:// kick
- if(chance <= 60){
- rate = true;
- return rate;
- }
- case 3://punt
- if(chance <= 70){
- rate = true;
- return rate;
- }
- case 4:// throw
- if(chance <= 50){
- rate = true;
- return rate;
- }
- case 5:// smash
- if(chance <= 95){
- rate = true;
- return rate;
- }
- case 6://shiv
- if(chance <= 80){
- rate = true;
- return rate;
- }
- case 7://punches
- if(chance <= 60){
- rate = true;
- return rate;
- }
- case 8://slap
- if(chance <= 75){
- rate = true;
- return rate;
- }
- case 9://roll
- if(chance <= 60){
- rate = true;
- return rate;
- }
- case 10:
- if(chance <= 50){
- rate = true;
- return rate;
- }
- }
- }// percent to hit all moves that do damage.
- int bossHp(int x){
- int hp;
- switch(x){
- case 1:
- hp = 100;
- return(hp);
- case 2:
- hp = 50;
- return(hp);
- case 3:
- hp = 250;
- return(hp);
- }
- }//boss hp
- int bossEn(int x){
- int en;
- switch(x){
- case 1:
- en = 10;
- return(en);
- case 2:
- en = 20;
- return(en);
- case 3:
- en = 5;
- return(en);
- }
- }//boss en
- int damage(int x, int hp, bool d){
- int punch = randomRange(5);
- int kick = randomRange(10);
- int punt = randomRange(5);
- int throe = randomRange(10);// wow throw is an operation. never lucky rubber ducky.
- int smash = randomRange(20);
- int shiv = randomRange(10);
- int punches = randomRange(3);
- int slap = randomRange(5);
- int roll = randomRange(10);
- int tantrum = randomRange(20);
- int defense;
- if(d){
- defense = 3;
- }
- else{
- defense = 0;
- }
- switch(x){
- case 1:
- if(punch >= 10){
- cout << "Critical hit!\n";
- }
- hp -= punch;
- return hp;
- case 2:
- if(kick >= 20){
- cout << "Critical hit!\n";
- }
- hp -= kick;
- return hp;
- case 3:
- if(punt >= 10){
- cout << "Critical hit!\n";
- }
- hp += defense;
- hp -= punt;
- return hp;
- case 4:
- if(throe >= 20){
- cout << "Critical hit!\n";
- }
- hp += defense;
- hp -= throe;
- return hp;
- case 5:
- if(smash >= 40){
- cout << "Critical hit!\n";
- }
- hp += defense;
- hp -= smash;
- return hp;
- case 6:
- if(shiv >= 20){
- cout << "Critical hit!\n";
- }
- hp += defense;
- hp -= shiv;
- return hp;
- case 7:
- if(punches >= 6){
- cout << "Critical hit!\n";
- }
- hp += defense;
- hp -= punches;
- return hp;
- case 8:
- if(slap >= 10){
- cout << "Critical hit!\n";
- }
- hp += defense;
- hp -= slap;
- return hp;
- case 9:
- if(roll >= 20){
- cout << "Critical hit!\n";
- }
- hp += defense;
- hp -= roll;
- return hp;
- case 10:
- if(tantrum >= 40){
- cout << "Critical hit!\n";
- }
- hp += defense;
- hp -= tantrum;
- return hp;
- }
- }// calculates damage on both characters
- int dialogue(int x,int y,int z, string name){
- //int x is which boss he talking to.
- //int y is which instance of dialogue it is.
- //int z is talk 1 || inspect 2
- switch(x){
- case 1://bistrugg
- switch(y){
- case 1:
- switch(z){
- case 1://talk 1
- cout << name << ": Calm down, I don't want to fight!\n";
- cout << "Bistrugg: Less talk, more SMASH!\n";
- return(1);
- case 2://talk 2
- cout << name << ": Wait-!\n";
- cout << "Bistrugg: I WILL SMASH YOU\n!";
- return(2);
- default://talk 3
- cout << name << ": Stop!\n";
- cout << "Bistrugg: SMASH ONLY\n";
- return(3);
- }
- case 2:
- switch(z){
- case 1:// inspect
- cout << "The monstrosity before you seems to be more muscle than man.\n";
- cout << "He lets out a roar as he charges forward, lifting his arms up to attack.\n";
- cout << "Given his size, his movements seem slow and predictable!\n";
- return(4);
- default://inspect 2
- cout << "You have learned all you can.\n";
- return(5);
- }
- }
- case 2://Farnsten
- switch(y){
- case 1:
- switch(z){
- case 1:// talk 1
- cout << name << ": Hey, wait!\n";
- cout << "It seems that Farnsten isn't interested in talking.\n";
- return(6);
- default:// talk 2
- cout << name << ": Stop-\n";
- cout << "Farnsten continues to attack\n";
- return(7);
- }
- case 2:
- switch(z){
- case 1://inspect 1
- cout << "The man appears to be nothing more than a blur as he dashes from place to place.\n";
- cout << "He is very fast but not very strong!\n";
- return(8);
- case 2://inspect 2
- cout << "As you watch him you begin to notice a pattern.\n";
- return(9);
- case 3://inspect 3
- cout << "The pattern becomes more noticeable as you watch.\n";
- return(10);
- default://inspect 4
- cout << "If you kick him now; you can disrupt his movements\n";
- return(11);
- }
- }
- case 3:// Lagrath
- switch(y){
- case 1:
- switch(z){
- case 1://talk 1
- cout << name << ": Wait! I just want to talk.\n";
- cout << "Lagrath: I shall talk but I shall not stop fighting.\n";
- return(12);
- case 2://talk 2
- cout << name << ": Who are you? Why are you attacking me?!";
- cout << "Lagrath: I am Lagrath! This is my mountain! You are trespassing!\n";
- return(13);
- case 3://talk 3
- cout << name << ": I'm just passing through. I didn't know this was your mountain. May I pass?\n";
- cout < "Lagrath: You are? Hum... perhaps. Do you swear not to harm my lands?\n";
- return(14);
- case 4://talk 4
- cout << name << ": I swear.\n";
- cout << "Lagrath: Very well. I shall let you go in peace. Farewell stranger.\n";
- return(15);
- }
- case 2:
- switch(z){
- case 1://inspect 1
- cout << "The man towers before you, looming like a mountain.\n";
- cout << "His height is matched only by his enormous girth.\n";
- cout << "It doesn't look like hitting him will have much of an affect.\n";
- return(16);
- default://inspect 2
- cout << "Fighting him doesn't seem realistic.\n";
- return(17);
- }
- }
- }
- }// talk and inspect dialogue
- int actions(){
- int action;
- cout << "What would you like to do:\n";
- cout << "1. Interact \t" << "2. Items \t" << "3. Investigate \t" << "4. Flee \n";
- cin >> action;
- switch(action){
- int choice;
- case 1://confront
- cout << "What would you like to do:\n";
- cout << "1. Punch \t" << "2. Kick \t" << "3.Dodge \t" << "4. Talk \n";
- cin >> choice;
- switch(choice){
- case 1:
- cout << "You try and throw a punch.\n";
- return(1);
- case 2:
- cout << "You try and kick him.\n";
- return(2);
- case 3:
- cout << "You decide to dodge.\n";
- return(3);
- case 4:
- return(4);
- }
- case 2://items
- cout << "What would you like to use:\n";
- cout << "1. Medical Kit \t" << "2. Use PCP \t" << "3. Wear Kevlar \t" << "4. Use Sleep Powder \n";
- cin >> choice;
- switch(choice){
- case 1:
- cout << "You chug back a health potion.\n";
- return(5);
- case 2:
- cout << "You shoot up some PCP to give you an edge in combat.\n";
- return(6);
- case 3:
- cout << "You put on a new kevlar vest to protect yourself.\n";
- return(7);
- case 4:
- cout << "You throw some sleep powder in his face. He falls asleep instantly.\n";
- return(8);
- }
- case 3://inspect
- return(9);
- case 4://run
- cout << "You try and run away but you trip over your cowardice and die instantly.\n";
- return(10);
- }
- }// all the actions
- int end(int ehp,int uhp, bool dip){
- if(ehp == 0){
- return(1);
- }
- if(uhp == 0){
- return(2);
- }
- if(dip == true){
- return(3);
- }
- }// checks for end of game scenario
- bool dodge(int x){
- bool dodged;
- if(x == 1){
- dodged = true;
- }
- else{
- dodged = false;
- }
- return dodged;
- }
- bool flipBool(bool x){
- if(x){
- x = false;
- return x;
- }
- }
- int main(int argc, char** argv) {
- bool running = true;
- while (running){
- bool playing = true;
- cout << "What is your name? \n";
- string name;
- cin >> name;
- int turn = 0;
- //defines boss stats.
- int boss;
- int eMove;
- int eHealth;
- int eEnergy;
- boss = random(3);
- eHealth = bossHp(boss);
- eEnergy = bossEn(boss);
- bool eAttackUp = false;
- //defines player stats.
- int uHealth = 50;
- int uEnergy = 5;
- bool userAttackUp = false;
- bool userDefenseUp = false;
- //status effects
- bool asleep = false;
- bool attack = false;
- bool defense = false;
- //core game variables
- int action;
- int sTimer;
- int aTimer;
- int dTimer;
- int talk = 1, inspect = 2;
- int tain;// talk or inspect
- bool diplomacy = false;
- int finish;
- bool uDodge;
- int dia;
- bool uAcc = false;
- bool conn = false;
- while(playing){
- tain = 0;
- attack = timer(aTimer);
- defense = timer(dTimer);
- asleep = sleep(sTimer);
- //writes how much hp and energy user and boss has each turn.
- userInterface(eHealth,eEnergy,uHealth,uEnergy);
- action = actions();// asks for user input.
- switch(action){
- case 1://punch
- conn = hit(1);
- if(conn){
- if(uEnergy > 0){
- eHealth = damage(1,eHealth,defense);
- uEnergy --;
- }
- else{
- cout << "You do not have enough energy for that!\n";
- }
- }
- else{
- cout << "You missed!";
- }
- break;
- case 2://kick
- if(uEnergy > 0){
- eHealth = damage(2,eHealth,defense);
- uEnergy --;
- }
- else{
- cout << "You do not have enough energy for that!\n";
- }
- break;
- case 3://dodge
- uDodge = true;
- break;
- case 4://talk
- tain = 1;
- dia = dialogue(boss, talk, tain, name);
- talk ++;
- break;
- case 5://hp
- if(uHealth > 0 && uHealth < 30){
- uHealth += 20;
- }
- else if(uHealth > 30 && uHealth < 50){
- uHealth = 50;
- }
- else{
- cout << "You are already at full Health.\n";
- }
- break;
- case 6://pcp
- attack = true;
- aTimer = 1;
- break;
- case 7://kev
- defense = true;
- dTimer = 1;
- break;
- case 8://sleep
- asleep = true;
- sTimer = 1;
- break;
- case 9://inspect
- tain = 2;
- dia = dialogue(boss, inspect, tain, name);
- inspect ++;
- break;
- case 10://flee
- uHealth = 0;
- break;
- }
- eMove = bossMoves(boss);
- switch(boss){
- case 1://bistrugg
- switch(eMove){
- case 1:
- if(uDodge){
- cout << "Bistrugg missed.\n";
- break;
- }
- else if(eAttackUp == true){
- uHealth = damage(3,uHealth,defense);
- uHealth = damage(3,uHealth,defense);
- eEnergy --;
- }
- else{
- uHealth = damage(3,uHealth,defense);
- eEnergy --;
- }
- break;
- case 2:
- if(uDodge){
- cout << "Bistrugg missed.\n";
- break;
- }
- else if(eAttackUp == true){
- uHealth = damage(4,uHealth,defense);
- uHealth = damage(4,uHealth,defense);
- eEnergy --;
- }
- else {
- uHealth = damage(4,uHealth,defense);
- eEnergy --;
- }
- break;
- case 3:
- if(uDodge){
- cout << "Bistrugg missed.\n";
- break;
- }
- else if(eAttackUp == true){
- uHealth = damage(4,uHealth,defense);
- uHealth = damage(4,uHealth,defense);
- eEnergy --;
- }
- else{
- uHealth = damage(4,uHealth,defense);
- eEnergy --;
- eAttackUp = true;
- }
- break;
- }
- case 2://Farnsten
- switch(eMove){
- if(turn == 1){
- uAcc = true;
- break;
- }
- case 1:
- if(uDodge){
- cout << "Farnsten missed.\n";
- break;
- }
- else{
- uHealth = damage(6,uHealth,defense);
- eEnergy --;
- break;
- }
- case 2:
- if(uDodge){
- cout << "Farnsten missed.\n";
- break;
- }
- else{
- uHealth = damage();
- }
- }
- }
- aTimer++;
- dTimer++;
- sTimer++;
- if(boss == 1 && eEnergy == 0){
- diplomacy = true;
- }//boss pacifist 1
- if(boss == 2 && dia == 11 && action == 2){
- diplomacy = true;
- }//boss pacifist 2
- if(boss == 3 && dia == 15){
- diplomacy = true;
- }//boss pacifist 3
- finish = end(eHealth,uHealth,diplomacy);
- turn += 1;//increments turn
- switch(finish){//
- case 1:
- cout << "you have defeated your opponent!\n";
- playing = false;
- break;
- case 2:
- cout << "You have been defeated!\n";
- playing = false;
- break;
- case 3:
- cout << "Wow, you talked your way out like a coward. Good job... I guess.\n";
- playing = false;
- break;
- }
- }
- cout << endl << "Would you like to play again?\n";
- string close;
- cin >> close;
- if(close == "no"){
- running = false;
- }
- }
- }// if u run it rn it will have errors, in process of adding something i forgot so theres a half finished statement for farnsten punches rn.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement