1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
/* Attack, health, armor and level will be passed into ResultTest by
reference. User will select basics and will be faced with a random
enemy. If user wins battle, ResultTest returns SUCCESS. Loses, LOSS.
LEVEL - Each level above the enemy will grant a 0.5 attack bonus. Each
level below the enemy will subtract 0.5 attack.
ARMOR - Each point of armor will subtract 0.2 attack from the oncoming
attack.
HEALTH - Starting health
ATTACK - damage
Function will take in player's level, and references to enemy stats
which begin at 0, and
initiate a random level for a mob, and return results to
main.
*/
#include <iostream>
#include <vector> // needed for vector arrays
using namespace std;
enum ERR_CODE { SUCCESS, LOSS }; // success = 0; error = 1
ERR_CODE ResultTest(int, int&, int&, int&, int&);
void EnemyStats(double, int, double);
int main()
{
ERR_CODE result;
double AtkDamage, health, armor;
int level;
double EnemyAttack, EnemyArmor, EnemyHealth;
int EnemyLevel;
cout << "********BASIC CHARACTER CUSTOMIZATION********";
cout << "Level: " ;
cin >> level;
health = level * 7.25;
AtkDamage = level * 2.25;
armor = level * 0.25;
ResultTest(level, EnemyLevel, EnemyAttack, EnemyArmor, EnemyHealth);
cout << "You are standing outside ";
srand ( time(NULL) );
int number = rand() % 5 + 1;
switch(number)
{
case 1:
cout << "a pizza shop. ";
break;
case 2:
cout << "your house. ";
break;
case 3:
cout << "an apartment complex. ";
break;
case 4:
cout << "the zoo. ";
break;
case 5:
cout << "a bookstore. ";
break;
}
cout << " You see a zombie in the distance. It rushes at you.\n";
EnemyStats(EnemyHealth, EnemyLevel, EnemyArmor);
cin.get();
return 0;
}
ERR_CODE ResultTest(int Level, int &rEnemyLevel, double &rEnemyAttack, double &rEnemyArmor, double &rEnemyHealth)
{
srand ( time(NULL) ); // initialize random seed
rEnemyLevel = rand() % Level * 1.25 + 1; // maximum enemy level possible is player level times 1.25, minimum 1
rEnemyAttack = rEnemyLevel * 2.25;
rEnemyHealth = rEnemyLevel * 7.25;
rEnemyArmor = rEnemyLevel * 0.25;
return SUCCESS;
}
void EnemyStats(double cEnemyHealth, int cEnemyLevel, double cEnemyArmor)
{
cout << "Its stats are:\n\
Health: " << cEnemyHealth << endl;
cout << "Armor: " << cEnemyArmor << endl;
cout << "Level: " << cEnemyLevel << endl;
}
|