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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
|
#include <iostream>
#include <string>
#include <conio.h>
#include <time.h>
using namespace std;
struct orc
{
char name[20];
int mindamage;
int maxdamage;
int armor;
int hp;
int agility;
};
struct item
{
char name[30];
std::string description;
std::string call;
};
struct wep
{
char name[30];
int mindmg;
int maxdmg;
std::string description;
std::string call;
};
int main()
{
//ORC STATS
orc weak =
{
"Weak Orc",
1, //min damage
3, //max damage
1, //armor
8, //hp
6, //agility
};
orc regular =
{
"Orc",
2,
5,
2,
12,
7,
};
orc strong =
{
"Strong Orc",
3,
7,
3,
15,
8,
};
orc enemy;
//ITEM STATS
item whpot =
{
"(whp) Weak Health Potion",
"A Weak Health Potion heals %10 of your hit points",
"whp",
};
item hpot =
{
"(hp) Health Potion",
"A Health Potion heals %30 of your hit points",
"hp",
};
item shpot =
{
"(shp) Strong Health Potion",
"A Strong Health Potion completely heals your hit points",
"shp",
};
item empty =
{
"(empty)",
"A slot may hold an item",
"",
};
item slot1, slot2, slot3, slot4;
//WEAPON STATS
wep wempty =
{
"(bh) bare hands",
1,
2,
"Desperate times call for desperate methods...",
"bh",
};
wep rdagger =
{
"(rd) rusty dagger",
1,
4,
"the dull blade is covered in rust",
"rd",
};
wep rhand;
//PROGRAM RANDOMLY SELECTS ORC TYPE
cout << "\n\nFate rolls a dice for you, revealing your enemy...\n\n" << endl;
getch();
srand (time(NULL));
int iRandom = rand() % 10 + 1;
if (iRandom <= 5)
{
enemy = weak;
cout << "A weak orc limps into the arena, still bleeding from an earlier match.";
}
else if (iRandom <= 9)
{
enemy = regular;
cout << "A common orc enters the arena, his blood red eyes locked directly on yours.";
}
else
{
enemy = strong;
cout << "A strong orc dashes into the arena directly at you!";
}
//STATS
int hp = 20;
int maxhp = 20;
int agility = 5;
int amindmg; //active min and max damage, these are assigned weapon stats.
int amaxdmg;
int armor = 3; //assigned armor value from worn armor. given a value for now.
//INVENTORY
rhand = wempty;
slot1 = hpot;
slot2 = whpot;
slot3 = whpot;
slot4 = whpot;
string icommand;
do {
cout << "\n\n\n**************************\nYour Hitpoints: (" << hp << ")" << endl;
cout << ""<<enemy.name << "\'s Hitpoints: (" << enemy.hp << ")\n";
cout << "**************************\n\n";
cout << "(a)ttack\n"
"(d)odge\n";
string orcroll;
int iRandom = rand() % 10 + 1; //roll to see what orc does
if (iRandom <= 5) orcroll = "a";
else orcroll = "d";
int ydmg;
int edmg;
amaxdmg = rhand.maxdmg;
amindmg = rhand.mindmg;
cin >> icommand;
//PLAYER'S ATTACK
if ((icommand == "a")&(orcroll == "a"))
{
int iRandom = rand() % 20 + 1; //player's roll to hit
if (iRandom < 2*agility)
{
int iRandom = rand() % 20 + 1; //rolls for orc dodge
if (iRandom < 0.5*enemy.agility)
{
cout << "\n\n\nThe " << enemy.name << " dodges your attack!";
}else if (iRandom == 0.5*enemy.agility)
{
cout << "\n\n\nThe " << enemy.name << " narrowly dodges your attack!";
}else
{
int ydmg = rand() % amaxdmg + (amindmg);
enemy.hp -= ydmg;
cout << "\n\n\nYou hit the " << enemy.name << " for " << ydmg << " damage";
}
}else if (iRandom = 2*agility)
{
int iRandom = rand() % 20 + 1; //rolls for orc dodge
if (iRandom < 0.5*enemy.agility)
{
cout << "\n\n\nThe " << enemy.name << " dodges your attack!";
}else if (iRandom == 0.5*enemy.agility)
{
cout << "\n\n\nThe " << enemy.name << " narrowly dodges your attack!";
}else
{
int ydmg = 1.5*(rand() % amaxdmg + (amindmg));
enemy.hp -= ydmg;
cout << "\n\n\nYou critically hit the " << enemy.name << " for " << ydmg << " damage";
}
}else
cout << "\n\n\nYou missed\n";
}else if ((icommand=="a")&(orcroll=="d"))
{
cout << "\n\nThe " << enemy.name << " tries dodging your attack!\n";
getch();
int iRandom = rand() % 20 + 1; //orc rolls for dodge
if (iRandom <= 1.5*agility)
{
cout << "\n\nThe " << enemy.name << " has dodged your attack\n";
getch();
cout << "\n\nYou are stunned\n";
getch();
int iRandom = rand() % 20 + 1; //Orc rolls to hit
if (iRandom < 2*enemy.agility)
{
int edmg = (rand() % enemy.maxdamage + (enemy.mindamage));
hp -=edmg;
cout << "\n\n\nThe " << enemy.name << " hits you for " << edmg << " damage!";
}else if (iRandom == 2*enemy.agility)
{
int edmg = 1.5*(rand() % enemy.maxdamage + (enemy.mindamage));
hp -=edmg;
cout << "\n\n\nThe " << enemy.name << " critically hits you for " << edmg << " damage!";
}else
{
cout << "\n\nThe " << enemy.name << " misses you.";
}
}else
{
int iRandom = rand() % 20 + 1; //player's roll to hit
if (iRandom < 1.5*agility)
{
ydmg = rand() % amaxdmg + (amindmg);
enemy.hp -= ydmg;
cout << "\n\nYou hit the " << enemy.name << " for " << ydmg << " damage";
}else if (iRandom == 1.5*agility)
{
ydmg = 1.5*(rand() % amaxdmg + (amindmg));
enemy.hp -= ydmg;
cout << "\n\nYou critically hit the " << enemy.name << " for " << ydmg << " damage";
}else
{
cout << "\n\nYou missed";
}
}
}else cout << "\n\nPlease enter a valid command.";
// END INVENTORY
}while
(icommand != "d"); //closes do while for attacking, stops loop when you hit d.
return 0;
}
|