need help with my text rpg
here it is, kind of long
Code:
#include<stdio.h>
#include<stdlib.h>
//attack function
int attackm(int,int,int,int,int,int,int,int,int,int);
//menu function
int menu(void);
//stats function
void stats(int,int,int,int,int,int,int);
//continue function
void cont(void);
main(){
//name
char name[20];
//class scan
int class1,class2;
//1st classes
int warrior,archer,thief,mage,priest;
//2nd classes
int knight,sniper,assassain,wizard,pope;
//gold
int gold=0;
//attack
int attack;
//weapons
int sword=20,bow=15,dagger=12,staff=5;
//def
int armor=0;
//armor
int mail=50,leather=30,cloth=10;
//exp
int exp=0;
//hp
int hp=0;
int chp=0;
//mp
int mp=0;
int cmp=0;
//***Town Menus***//
//radan
int radan=0,fradan;
//**********Enemys******************//
//dire wolf
int dwhp=80,dwmp=0,dwatck=10,dwdef=0,dwexp=35;
//ask for name
printf("What is your name?\n");
scanf("%s",name);
system("CLS");
//ask for class
printf("What class would you like to learn in?\n");
printf("1.Warrior\n");
printf("2.Archer\n");
printf("3.Thief\n");
printf("4.Mage\n");
printf("5.Priest\n");
scanf("%d",&class1);
//class switch
switch(class1){
case 1:
printf("You are now a Warrior\n");
hp=100;
chp=100;
mp=10;
cmp=10;
printf("You recieve a Sword\n");
attack=sword;
printf("You recieve Mail\n");
armor=armor+mail;
printf("You recieve 500 gold\n");
gold=gold+500;
break;
case 2:
printf("You are now an Archer\n");
hp=80;
chp=80;
mp=25;
cmp=25;
printf("You recieve a Bow\n");
attack=bow;
printf("You recieve Leather\n");
armor=armor+leather;
printf("You recieve 500 gold\n");
gold=gold+500;
break;
case 3:
printf("You are now a Thief\n");
hp=70;
chp=70;
mp=30;
cmp=30;
printf("You recieve a Dagger\n");
attack=dagger;
printf("You recieve Leather\n");
armor=armor+leather;
printf("You recieve 500 gold\n");
gold=gold+500;
break;
case 4:
printf("You are now a Mage\n");
hp=60;
chp=60;
mp=90;
cmp=90;
printf("You recieve a Staff\n");
attack=staff;
printf("You recieve Cloth\n");
armor=armor+cloth;
printf("You recieve 500 gold\n");
gold=gold+500;
break;
case 5:
printf("You are now a Priest\n");
hp=50;
chp=50;
mp=100;
cmp=100;
printf("You recieve a Staff\n");
attack=staff;
printf("You recieve Cloth\n");
armor=armor+cloth;
printf("You recieve 500 gold\n");
gold=gold+500;
break;
}
cont();
//radan
printf("You enter the town of Radan\n");
//radan menu
radan=menu();
//radan menu switch
while(radan==menu()){
switch(radan){
case 1:
system("CLS");
printf("1.Dire Wolf\n");
printf("2.Bear\n");
scanf("%d",&fradan);
switch(fradan){
case 1:
attackm(chp,cmp,attack,armor,exp,dwhp,dwmp,dwatck,dwdef,dwexp);
break;
}
case 5:
stats(hp,mp,attack,armor,exp,chp,cmp);
break;
}
}
return 0;
}
//attack function
int attackm(int hp,int mp,int atck,int def,int exp,int ehp,int emp,int eatck,int edef,int eexp){
int amenu=0;
while(amenu==0){
system("CLS");
printf("1.Attack\n");
printf("2.Magic\n");
printf("3.Items\n");
printf("4.Run (roll to run)\n");
scanf("%d",&amenu);
}
if(ehp<=0){
printf("You win!\n");
printf("You gain %d EXP\n!",eexp);
exp=exp+eexp;
cont();
}
switch(amenu){
case 1:
system("CLS");
ehp=ehp-atck;
if(ehp<=0){
ehp=0;
}
printf("You do %d damage, enemy has %d HP left\n",atck,ehp);
hp=hp-eatck;
printf("You take %d damage, you have %d HP left\n",eatck,hp);
cont();
amenu=0;
break;
}
}
//menu function
int menu(void){
int menu;
printf("1.Fight\n");
printf("2.Shop\n");
printf("3.Inn\n");
printf("4.Inventory\n");
printf("5.Stats\n");
printf("6.Head to next area (look out for monsters on the way)\n");
scanf("%d",&menu);
return menu;
}
//stats function
void stats(int fhp,int fmp,int fattack,int fdefense,int fexp,int chp,int cmp){
system("CLS");
printf("%d/%d HP\n",chp,fhp);
printf("%d/%d MP\n",cmp,fmp);
printf("%d Armor\n",fdefense);
printf("%d Attack\n",fattack);
printf("%d EXP\n",fexp);
cont();
}
//cont funcion
void cont(void){
printf("\nHit any key to continue(sometimes you have to hit it twice)\n");
getchar();
getchar();
system("CLS");
}
some probles i am having are:
*pretty much the whole radan menu, when i run it at first and make a selection, it asks again, then it works after the second time you type in the selection. when you go back after going to stats from that, you cant go into fight, just stats again.
*when you go into fight, then finish attacking, it will show the stats menu, then close
*the reason i have while(radan==menu()) is so that it continues going through the switch statement and takes you back to the menu so you can make more selections, apparently that dosnt work
thanks in advance for the help, please point out anything else that is wrong if you can