Alright, I can't seem to figure out a couple of things here. I'm making an RPG and am having a couple probs with the fighting. First, I need help with the life. I want it so when my life or mlife is <=0, they die. Just a simple message to say "You killed the enemy" or whatever and brings it back to the main forest menu. I can't figure out what to use for that and where to put it.
Also, when I want to run from the enemy, I want it to go back to the main forest menu and be able to go from there.
I think that's about it so far. I may need help later on with file saving. I looked through past threads and so far haven't found much. If anyone can help, I would greatly appreciate it. Thanks!
Code:switch (town1) { case 2: cout<<"Legend of the Green Dragon - Forest"<<'\n'; cout<<"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"<<'\n'; cout<<" "<<'\n'; cout<<name<<", you slowly walk into the forest. As you walk through, you're careful to"<<'\n'; cout<<"notice anything that may seem out of the ordinary. Although, around here,"<<'\n'; cout<<"strange is a normal thing."<<'\n'; cout<<" "<<'\n'; cout<<"What would you like to do?"<<'\n'; cout<<"(1)Kill something"<<'\n'; cout <<"(2)Look for the Green Dragon"<<'\n'; cout <<"(3)Leave the forest"<<'\n'; cin>>forest; cin.ignore(80, '\n'); system("CLS"); switch (forest) { case 1: srand((unsigned)time(NULL)); monster = (rand() %1) + 1; switch (monster) { case 1: strcpy(monster1, "an Old Man"); mlife=20*level; monmaxattack=monmaxattack*level; monminattack=monminattack+level; break; } cout<<"Legend of the Green Dragon - Forest"<<'\n'; cout<<"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"<<'\n'; cout<<" "<<'\n'; cout<<"You've encountered "<< monster1 <<"."<<'\n'; cout<<"Your hit points: "<<life<<'\n'; cout<<"Enemy hit points: "<<mlife<<'\n'; cout<<"(1)Attack"<<'\n'; cout<<"(2)Run"<<'\n'; cin>>fightchoice; system("CLS"); do { switch(fightchoice) { case 1: srand((unsigned)time(NULL)); damage = (rand() %maxattack) +minattack; cout<<"Legend of the Green Dragon - Forest"<<'\n'; cout<<"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"<<'\n'; cout<<" "<<'\n'; cout<<"You dealt "<<damage<<" damage"<<'\n'; mlife=mlife-damage; mondamage = (rand() %monmaxattack) +monminattack; cout<<"The enemy dealt "<<mondamage<<" damage"<<'\n'; life=life-mondamage; cout<<" "<<'\n'; cout<<"Enemy: "<<monster1<<'\n'; cout<<" "<<'\n'; cout<<"Your hit points: "<<life<<'\n'; cout<<"Enemy hit points: "<<mlife<<'\n'; cout<<"(1)Attack"<<'\n'; cout<<"(2)Run"<<'\n'; cin>>fightchoice; system("CLS"); break; gained = (rand() %(experience*level)) + 1; experience=experience+gained; cout<<"You gained "<<experience<<" experience"<<'\n'; if(experience=(300*level)) { level=level+1; } case 2: cout<<"You run from the enemy"<<'\n'; break; } }while(fightchoice!=4); } } return 0; }



LinkBack URL
About LinkBacks


