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
|
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int combatSystem(int playerHP, int enemyHP);
int showEnemyHP(int enemyHP);
int showPlayerHP(int playerHP);
int playerHitResult(int enemyHP);
int enemyHitResult(int playerHP);
int playerRegDmg();
int playerCritDmg();
int enemyRegDmg();
int enemyCritDmg();
int d20();
int playerHP = 59, int enemyHP = 178;
int main() {
srand((unsigned)time(NULL));
int choice;
cout << endl;
cout << "A Stone Golem claws up through the road in front of you." << endl;
cout << "What do you do???" << endl;
cout << endl;
system("PAUSE");
cout << endl;
cout << "Do you Attack or Run away?" << endl;
cout << "Attack = 1 Run = 2 " << endl;
cin >> choice;
if (choice == 1)
{
combatSystem(playerHP, enemyHP);
}
else if (choice == 2)
{
cout << "You chose to run away from the Stone Golem." << endl;
cout << endl;
}
else
{
cout << "That is not a valid choice." << endl;
cout << endl;
return main();
}
system("PAUSE");
return 0;
}
int combatSystem(int playerHP, int enemyHP) {
// Stone Golem - HP = 178, AC = 18, +10 to hit, 2x Slam attacks, dmg = 3d8 +6 bludgeoning damage.
// Player - HP = 59, AC = 21, +8 to hit, 2x attacks, 1d12 + 5 slashing damage.
//int playerHP = 59, enemyHP = 178;
do
{
enemyHP = showEnemyHP(enemyHP);
playerHP = showPlayerHP(playerHP);
playerHitResult(enemyHP);
enemyHitResult(playerHP);
} while (enemyHP > 0 && playerHP > 0);
return 0;
}
int showEnemyHP(int enemyHP) {
enemyHP = enemyHP;
return enemyHP;
}
int showPlayerHP(int playerHP) {
playerHP = playerHP;
return playerHP;
}
int playerHitResult(int enemyHP) {
int hit_result, d20;
int enemyAC = 18;
int playerPlusHit = 8;
d20 = rand() % 20 + 1;
hit_result = playerPlusHit + d20;
if (d20 == 20) {
cout << endl;
cout << "Player rolled a " << d20 << endl;
cout << "Player's score to hit is " << hit_result << " vs AC " << enemyAC << endl;
cout << "CRITICAL HIT! Player rolls weapon dice twice!" << endl;
cout << endl;
enemyHP = enemyHP - playerCritDmg();
cout << "Stone Golem's HP is now " << showEnemyHP(enemyHP) << endl;
return enemyHP;
}
else if (d20 == 1) {
cout << endl;
cout << "Player rolled a " << d20 << endl;
cout << "Critical FAIL !!! Player MISSES!" << endl;
cout << endl;
}
else if (hit_result >= enemyAC) {
cout << endl;
cout << "Player rolled a " << d20 << endl;
cout << "Player's score to hit is " << hit_result << " vs AC " << enemyAC << endl;
cout << "Player Hits!" << endl;
cout << endl;
enemyHP = enemyHP - playerRegDmg();
cout << "Stone Golem's HP is now " << showEnemyHP(enemyHP) << endl;
return enemyHP;
}
else {
cout << endl;
cout << "Player rolled a " << d20 << endl;
cout << "Player's score to hit is " << hit_result << " vs AC " << enemyAC << endl;
cout << "Player Missed..." << endl;
cout << endl;
}
return 0;
}
int enemyHitResult(int playerHP) {
int hit_result, d20;
int playerAC = 21;
int enemyPlusHit = 10;
d20 = rand() % 20 + 1;
hit_result = enemyPlusHit + d20;
if (d20 == 20) {
cout << endl;
cout << "Stone Golem rolls a " << d20 << endl;
cout << "Stone Golem score to hit is " << hit_result << " vs AC " << playerAC << endl;
cout << "CRITICAL HIT! Stone Golem rolls his weapon dice twice!" << endl;
cout << endl;
playerHP = playerHP - enemyCritDmg();
cout << "Player's HP is now " << showPlayerHP(playerHP) << endl;
return playerHP;
}
else if (d20 == 1) {
cout << endl;
cout << "Stone Golem rolls a " << d20 << endl;
cout << "Stone Golem score to hit is " << hit_result << " vs AC " << playerAC << endl;
cout << "Critical FAIL !!! Stone Golem MISSES!" << endl;
cout << endl;
}
else if (hit_result >= playerAC) {
cout << endl;
cout << "Stone Golem rolls a " << d20 << endl;
cout << "Stone Golem score to hit is " << hit_result << " vs AC " << playerAC << endl;
cout << "Stone Golem Hits!" << endl;
cout << endl;
playerHP = playerHP - enemyRegDmg();
cout << "Player's HP is now " << showPlayerHP(playerHP) << endl;
return playerHP;
}
else {
cout << endl;
cout << "Stone Golem rolls a " << d20 << endl;
cout << "Stone Golem score to hit is " << hit_result << " vs AC " << playerAC << endl;
cout << "Stone Golem Missed..." << endl;
cout << endl;
}
return 0;
}
int playerRegDmg() { //dmg = d12 + 5 slashing damage
int reg_dmg, d12;
int playerStrMod = 5;
d12 = rand() % 12 + 1;
reg_dmg = playerStrMod + d12;
cout << "Player's Greataxe damage is " << reg_dmg << endl;
return reg_dmg;
}
int playerCritDmg() {
int crit_dmg, d12a, d12b;
int playerStrMod = 5;
d12a = rand() % 12 + 1;
d12b = rand() % 12 + 1;
crit_dmg = d12a + d12b + playerStrMod;
cout << "Player's Greataxe damage is " << crit_dmg << endl;
return crit_dmg;
}
int enemyRegDmg() { //dmg = 3d8 + 6 bludgeoning damage
int reg_dmg, d8a, d8b, d8c;
int enemyStrMod = 6;
d8a = rand() % 8 + 1;
d8b = rand() % 8 + 1;
d8c = rand() % 8 + 1;
reg_dmg = enemyStrMod + d8a + d8b + d8c;
cout << "Stone Golem's Slam damage is " << reg_dmg << endl;
return reg_dmg;
}
int enemyCritDmg() {
int crit_dmg, d8a, d8b, d8c, d8d, d8e, d8f;
int enemyStrMod = 6;
d8a = rand() % 8 + 1;
d8b = rand() % 8 + 1;
d8c = rand() % 8 + 1;
d8d = rand() % 8 + 1;
d8e = rand() % 8 + 1;
d8f = rand() % 8 + 1;
crit_dmg = d8a + d8b + d8c + d8d + d8e + d8f + enemyStrMod;
cout << "Stone Golem's Critical Slam damage is " << crit_dmg << endl;
return crit_dmg;
}
int d20() {
int d20_result;
d20_result = rand() % 20 + 1;
return d20_result;
}
| |