Code:
#include <stdio.h>#include <stdlib.h>
#include <time.h>
#include <string.h>
int
main()
{
int player, attack, monster, attack2, initiate, retal, ogre, gold, n, d, sword;
int loot, selection, direction, mask, m, def, wizard;
int cont, potion, boss;
char name[100];
boss = 1000;
ogre = 150;
wizard = 300;
potion = 0;
monster = 100;
player = 1000;
gold = 0;
n = 0;//sword att
d = 0;//sword def
m = 0;//bear mask att
def = 0;//bear mask def
printf("----------------------------------------------------------------------------\n");
printf("----------------------------------------------------------------------------\n");
printf(" III III II IIIIIIII III IIIIIIII IIIIIIII IIIIIII \n");
printf(" III III IIII III III III IIIIIIII III III III IIII \n");
printf(" III I III II II IIIIIIII III II II IIIIIIII III III \n");
printf(" III II II III IIIIIIII III III III II II III III III III \n");
printf(" IIIII IIIII III III III III IIIIIII IIIIIIII III III III IIII \n");
printf(" III III III III III III IIIIIII IIIIIIII III III IIIIIII \n");
printf("-----------------------------------------------------------------------------\n");
printf("-----------------------------------------------------------------------------\n");
printf("By, Hool\n\n\n\n\n");
printf(" PRESS ENTER TO CONTINUE!\n\n\n\n\n\n\n\n");
printf("TIP: Press 1, 2, or 3 then enter when making selections.\n");
getch();
system("cls");
printf("What is your name> ");
scanf("%s", &name);
system("cls");
printf("Well nice too meet you %s, you look like a mighty fine warrior!", name);
getch();
system("cls");
//Introduction
sleep(1000);
printf("%s have entered the world of Sindaria!\n\nThe land of mystical beings and ferocious creatures!\n\n\n", name);
sleep(1000);
printf("This land has been ruled by an evil Emperor known as Jarhuvis\n");
sleep(1000);
printf("You are our last hope for destroying this evil creature\n");
getch();
system("cls");
printf("\n\n\n\n\n\n\n %s please save us\n");
getch();
system("cls");
//Beginning of journey
printf("Which direction would you like to start your journey?\n");
printf("1.North\n2.South\n3.East\n4.West\n");
scanf("%d", &direction);
if (direction == 4 || direction == 3){
printf("This path is blocked try another route\n");
system("pause");
return(0);
}
if (direction == 1){
printf("You have chosen to head North\n");
sleep(1000);
printf("You begin your journey north down an old dirt road\n\n");
sleep(1000);
printf("You come across a group of woods known as the Fernot forest\n");
sleep(1000);
printf("From inside a voice calls to you\n");
sleep(1000);
printf("%s cccommmmeeee clooosssseerrrr\n", name);
sleep(1000);
printf("You enter the forest and come across an old wrinkly man\n");
sleep(1000);
printf("'Hello traveler, what is your reason for entering my forest?'\n");
sleep(1000);
printf("'Uuuhh.. I..'\n");
sleep(2000);
printf("'Ha nevermind why! We will see how you hold up in my domain!'\n");
sleep(1000);
printf("With a sudden flash\nBANGG!\n");
sleep(1000);
printf("You notice the old man has disappeared\n");
sleep(1000);
printf("Whats that noise?!");
getch();
system("cls");
//----------------------------------------------------------------------------------------------
sleep(2000);
printf("\n\n\n\n\n\n\n Suddenly a Bear appears!\n");
sleep(2000);
printf("\n\n What should you do?!\n\n");
while (monster <= 100 && monster > 0 && player <= 1000 && player > 0){
printf("1.Attack\n2.Defend\n");
scanf("%d", &attack2);
//Monsters Health & Damage recieved
if (attack2 == 1){
srand((unsigned)time(NULL));
int attack = rand() % 50 + n;
monster = monster - attack;
//Players Health & Damage recieved
srand((unsigned)time(NULL));
int retal = rand() % 38 ;
player = player - retal;
printf("You attack the Bear!\n");
printf("It attacks you back!\n");
printf("Bear's health: %d\n", monster);
printf("Your health: %d\n", player);
getch();
system("cls");
}
else if (attack2 == 2){
//Monster Health & Damage Recieved
srand((unsigned)time(NULL));
int attack2 = rand()% 25 + (n/2);
monster = monster - attack2;
//Player health & damage recieved
srand((unsigned)time(NULL));
int retal = rand() % 25 - d;
player = player - retal;
printf("You defend against the Bear!\n");
printf("The bear bites into your armor!\n");
printf("Bear's health: %d\n", monster);
printf("Your health: %d\n", player);
getch();
system("cls");
}
if (monster <=0 ){
printf("You have slayed the Bear!\n");
//Loot system
srand((unsigned)time(NULL));
int loot = rand()% 50;
printf("You have loot %d gold off the body\n", loot);
gold += loot;
printf("Current gold: %d\n", gold);
}
else if (player == 0 || player <0){
printf("Player is dead\n");
printf(" GAME OVER\n");
system("pause");
return(0);
}
}
getch();
system("cls");
printf("Would you like to take the bears head and wear it as a mask?\n\n");
sleep(2000);
printf("This new mask will increase attack but lower your defense.\n");
printf("\n\n\n\n\n\n\n 1.Yes\n 2.No\n");
scanf("%d", &mask);
if (mask == 1){
m = 15;
def = 15;
printf("You now have the eyes of the BEAR!\n");
}
else if (mask == 2){
printf("Sucks to be normal\n");
}
getch();
system("cls");
printf("You continue down the path of the forest leaving the dead bear carcass behind you\n");
sleep(1000);
printf("A wooden chest is off in the distance sitting on a stump\n");
sleep(1000);
printf("Making your way over to it you hear a laughter from behind you\n");
getch();
system("cls");
printf("\n\n\n\n HA!\n\n");
sleep(500);
printf(" HA!\n\n");
sleep(500);
printf(" HA!\n\n");
getch();
system("cls");
printf("\n\n\n\n\n\n The old man from earlier appears!\n");
getch();
system("cls");
printf("\n\n\n\n 'I WARNED YOU WOULDN'T SURVIVE IN MY FOREST!'\n\n");
sleep(1000);
printf("\n ' I AM THE ALL POWERFUL ZUCHOR, YOU WILL BE MY NEXT VICTIM!!!'\n");
getch();
system("cls");
//----------------------------------------------------------------------------------------------------------------------------------
while (wizard <= 300 && wizard > 0 && player <= 1000 && player > 0){
printf("1.Attack\n2.Defend\n");
scanf("%d", &attack2);
//Wizards Health & Damage recieved
if (attack2 == 1){
srand((unsigned)time(NULL));
int attack = rand() % 50 + (n + m);
wizard = wizard - attack;
//Players Health & Damage recieved
srand((unsigned)time(NULL));
int retal = rand() % 80 ;
player = player - retal;
printf("You attack the Zuchor!\n");
printf("He cast a spell back at you!\n");
printf("Zuchor's health: %d\n", wizard);
printf("Your health: %d\n", player);
getch();
system("cls");
}
if (attack2 == 2){
//Monster Health & Damage Recieved
srand((unsigned)time(NULL));
int attack2 = rand()% 35 + (((n+m)/2));
wizard = wizard - attack2;
//Player health & damage recieved
srand((unsigned)time(NULL));
int retal = rand() % 55 - (d+def);
player = player - retal;
printf("You defend against the Zuchor's spells!\n");
printf("He cast a fire ball!\n");
printf("Zuchor's health: %d\n", wizard);
printf("Your health: %d\n", player);
getch();
system("cls");
}
if (wizard <=0 ){
printf("You have destroyed Zuchor!\n");
//Loot system
srand((unsigned)time(NULL));
int loot = rand()% 100;
printf("You have loot %d gold off the body\n", loot);
gold += loot;
printf("Current gold: %d\n", gold);
sleep(1000);
printf("You obtain a health potion\n");
potion = 1;
}
else if (player == 0 || player <0){
printf("Player is dead\n");
printf(" GAME OVER\n");
system("pause");
return(0);
}
}
//--------------------------------------------------------------------------------------------------------
//Merchant
getch();
system("cls");
printf("You feel exhausted after your battle but you can see the light at the end of the woods\n");
sleep(1000);
printf("As you finally break through the last of the trees you feel a sudden surge of relief\n");
sleep(1000);
printf("You start making your way down the a brick path that exist the woods\n\n");
sleep(1000);
printf("You hear a man's voice calling out");
sleep(1000);
printf("\n\n\n\n 'Ahoy ey mate!'\n\n");
getch();
system("cls");
printf("Its a man with a cart of items displayed");
getch();
system("cls");
printf("\n\n\n\n 'Hey traveler you want to have a look at my goods?'");
getch();
system("cls");
printf("%s- 'Sure why not'", name);
getch();
system("cls");
printf("What would you like to purchase?\n");
printf("1.Sword of Fury\n2.Steel Shield\n3.Exit\n");
scanf("%d", &selection);
if(selection == 1 && gold > 50){
n += 10;
gold -= 50;
sword = 1;
printf("You purchased: The Sword of Fury!\n");
sleep(1000);
printf("Current gold: %d\n", gold);
}
if(selection == 1 && gold < 50){
printf("Sorry you do not have enough gold\n");
}
if (selection == 2 && gold > 50){
d += 10;
gold -=50;
printf("You have purchased a Steel Shield!\n");
}
if (selection == 3){
}
getch();
system("cls");
printf("You see a dark castle with ominous clouds lingering over it\n");
sleep(1000);
printf("A chill runs through your spine...\n\n");
getch();
system("cls");
printf("\n\n\n\n\n\n\n ITS TIME TO HEAD TO THE FINAL BATTLE");
getch();
system("cls");
//---------------------------------------------------------------------------
//FINAL BATTLE!
printf("\n\n\n\n\n\n You find yourself at the gates of Jarhuvis' Castle");
getch();
system("cls");
printf("Pushing the gate with all your might the large doors swing open.\n\n");
sleep(1000);
printf("As you through the main hall your hear a menancing but powerful voice");
getch();
system("cls");
printf("\n\n\n\n\n\n\n I'VE BEEN EXPECTING YOU %s!!", name);
getch();
system("cls");
printf("\n\n\n\n\n\n\n SINDARIA IS MINE!");
getch();
system("cls");
printf("\n\n\n\n\n\n\n FINAL BATTLE!");
sleep(500);
printf("\n FINAL BATTLE!");
sleep(500);
printf("\n FINAL BATTLE!");
sleep(500);
printf("\n FINAL BATTLE!");
sleep(500);
printf("\n FINAL BATTLE!");
sleep(500);
printf("\n FINAL BATTLE!");
getch();
system("cls");
//End of Second Combat
while (boss <= 1000 && boss > 0 && player <= 2000 && player > 0){
printf("1.Attack\n2.Defend\n3.Potion\n");
scanf("%d", &attack2);
//ogres Health & Damage recieved
if (attack2 == 1){
srand((unsigned)time(NULL));
int attack = rand() % 50 + (n+m);
boss = boss - attack;
//Players Health & Damage recieved
srand((unsigned)time(NULL));
int retal = rand() % 90;
player = player - retal;
printf("You attack the Jarhuvis!\n");
printf("It attacks you back!\n");
printf("Jarhuvis' health: %d\n", boss);
printf("Your health: %d\n", player);
getch();
system("cls");
}
else if (attack2 == 2){
//Boss Health & Damage Recieved
srand((unsigned)time(NULL));
int attack2 = rand()% 25 + (((m+n)/2));
boss = boss - attack2;
//Player health & damage recieved
srand((unsigned)time(NULL));
int retal = rand() % 75 - d;
player = player - retal;
printf("You defend against the Jarhuvis'!\n");
printf("It attacks you back!\n");
printf("Jarhuvis' health: %d\n", boss);
printf("Your health: %d\n", player);
getch();
system("cls");
}
if (attack2 == 3 && potion != 0){
potion -= 1;
player += 200;
printf("You used your potion\n");
printf("You have healed yourself 200 life points\n");
printf("Current Health: %d\n", player);
}
else if (attack2 == 3 && potion == 0){
printf("You have no more potions sorry\n");
}
if (player <= 0){
printf("You are dead\n");
getch();
system("cls");
printf("\n\n\n\n\n GAME OVER!");
system("pause");
return(0);
}
if (boss <= 0){
printf("You have killed Jaharvis!!!\n");
}
}
sleep(1000);
getch();
system("cls");
printf("\n\n\n\n YOU HAVE SAVED SANDARIA!");
getch();
system("cls");
printf("\n\n\n\n\n\n YOU HAVE WON!");
getch();
printf("\n\n\n\n\n\n Programmed by, Hool");
printf("\n Story by, Hool\n");
system("pause");
return(0);
}
if (direction == 2){
printf("You head south\n");
sleep(2000);
printf("A wild ogre appears\n");
getch();
system("cls");
//-----------------------------------------------------------------------------------------
//End of Second Combat
while (ogre <= 150 && ogre > 0 && player <= 1000 && player > 0){
printf("1.Attack\n2.Defend\n");
scanf("%d", &attack2);
//ogres Health & Damage recieved
if (attack2 == 1){
srand((unsigned)time(NULL));
int attack = rand() % 50 + n;
ogre = ogre - attack;
//Players Health & Damage recieved
srand((unsigned)time(NULL));
int retal = rand() % 40;
player = player - retal;
printf("You attack the Ogre!\n");
printf("It attacks you back!\n");
printf("Ogre's health: %d\n", ogre);
printf("Your health: %d\n", player);
getch();
system("cls");
}
else if (attack2 == 2){
//Monster Health & Damage Recieved
srand((unsigned)time(NULL));
int attack2 = rand()% 25 + (n/2);
ogre = ogre - attack2;
//Player health & damage recieved
srand((unsigned)time(NULL));
int retal = rand() % 25 - d;
player = player - retal;
printf("You defend against the ogre!\n");
printf("It attacks you back!\n");
printf("ogre's health: %d\n", ogre);
printf("Your health: %d\n", player);
getch();
system("cls");
}
if (ogre <= 0){
printf("You have slayed the monster!\n");
srand((unsigned)time(NULL));
//loot system
int loot = rand()% 20;
printf("You have loot %d gold off the body\n", loot);
gold += loot;
printf("Current gold: %d\n", gold);
}
else if (player == 0 || player <0){
printf("Player is dead\n");
printf(" GAME OVER\n");
}
}
printf("Would you like to proceed?\n");
printf("1.Yes\n2.No Check health and gold first\n3.Shop\n");
scanf("%d", &cont);
if (cont == 1){
printf("Continuing\n");//Continue Journey
}
if (cont == 2){//Stats Check
printf("Your current health: %d\nYour current Gold: %d\n", player, gold);
}
if (cont == 3){//shop
printf("What would you like to purchase?\n");
printf("1.Sword of Fury\n2.Steel Shield\n3.Exit\n");
scanf("%d", &selection);
if(selection == 1 && sword ==1){
printf("Sorry you already own this weapon\n");
}
else if(selection == 1 && gold > 50){
n += 10;
gold -= 50;
sword = 1;
printf("You purchased: The Sword of Fury!");
sleep(2000);
printf("Current gold: %d\n", gold);
}
if(selection == 1 && gold < 50){
printf("Sorry you do not have enough gold\n");
}
if (selection == 2 && gold > 50){
d += 10;
gold -=50;
printf("You have purchased a Steel Shield!\n");
}
if (selection == 3){
}
printf("Go north for longer story\n");
}
system("pause");
return(0); }
//------------------------------------------------------------------------------------------------
}
here is the .exe