0

lol i have tried and tried and look and ignored it for a long time. but i just can't find this problem or find it's solution anywhere. Here it is i have a function called fight i need to call to it often but for some odd reason whenever i try to call to it, it just skips that entire line and goes on in the program. here is my complete code (i have commented out the music, it won't let me attach them.) thank you so much anyone who is willing to help!!!!!

```
#pragma hdrstop
#include <condefs.h>
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
#include <mmsystem.h> // mciSendString()
#pragma argsused
void questone(int & hp, int & gp, int & exp);
void fight (int & hp, int & gp, int & exp, int & agilitylvl, int & lvl1potions, int & lvl2potions, int & lvl3potions, int & demonpotions, int & dammage, int & def, int chp, int cgp, int cdammage, int cexp,char *name, int & nextlevel, int & maxhp, char *nextweapon, int & blocked, int & level);
void apothecary (int & lvl1potions, int & lvl2potions, int & lvl3potions, int & demonpotions, int & hp, int maxhp, int & gp);
void town (char *townname, int & hp, int & gp, int & exp, int & agilitylvl, int & lvl1potions, int & lvl2potions, int & lvl3potions, int & demonpotions, int & dammage, int & def, int & maxhp, int & level, int townnumber, int & draynorquestnumber);
void gameplaychoice (int & hp, int & gp, int & exp, int & agilitylvl, int & lvl1potions, int & lvl2potions, int & lvl3potions, int & demonpotions, int & dammage, int & def, int chp, int cgp, int cdammage, int cexp,char *name, int & nextlevel, int & maxhp, char *nextweapon, int & blocked, int & level, char *town);
void attack (int & hp, int dammage, int def, int & chp, int cdammage, char *name, int & gp, int cgp, int & nextlevel, int & exp, int cxp, int maxhp);
void usepotion (int & lvl1potions, int & lvl2potions, int & lvl3potions, int & demonpotions, int & hp, char *name, int maxhp);
int main(int argc, char **argv)
{
//mciSendString("play C:\\lndnchip.mid",NULL,0,NULL);
// charecter stuff
int maxhp;
int hp;
int gp=120;
int exp=0;
int nextlevel=80;
int level=1;
int agilitylvl=0;
int def=0;
int dammage;
// items
int lvl1potions=0;
int lvl2potions=0;
int lvl3potions=0;
int demonpotions=0;
int secretitems=0;
// misc
int score=0;
int charecter;
int hplost;
int choice;
int blocked=0;
cout << "**************************************" << endl;
cout << "* *" << endl;
cout << "* A role playing game by Nate Nelson *" << endl;
cout << "* *" << endl;
cout << "**************************************" << endl << endl;
cout << "choose your character" << endl;
cout << "1: Barbarian" << endl;
cout << "2: Wizard of The Old Teachings" << endl;
cout << "3: Gnome" << endl << endl;
cin >> charecter;
if (charecter == 1){
cout << "You have chosen the nobelist and fiercest warrior in all the land, Abdazar!" << endl;
cout << "the time has now come to choose you mode of battle." << endl << endl;
cout << "Press any key to continue..." << endl << endl;
getch();
cout << "1: I would like to fight with a Giant Axe." << endl;
cout << "2: I would like to fight with a Sword and Shield." << endl;
cin >> choice;
if (choice == 1){
cout << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl;
hp = 50;
maxhp = 50;
def = 2;
cout << "Your weapon shall be an Axe like tree root." << endl << endl;
cout << "As your adventure begins you decide to randomly choose a direction" << endl;
cout << "You have stumbled upon a Goblin Warrior, he has spoted you and" << endl;
cout << "wishes to fight!" << endl;
cout << "You Valiantly fight the monster for your life." << endl << endl;
dammage = 10;
int goblinhp = 20;
int goblingp = 20;
//1st attack
hplost = hp;
goblinhp = goblinhp-10;
hp = hp-5+def;
goblinhp = goblinhp-10;
hp = hp-5+def;
hplost = hplost-hp;
gp = gp+goblingp;
hp = hp+5;
exp = exp + 20;
cout << "you have fought valiently and killed the beast!" << endl;
cout << "your Hit points are now at " << hp << "." << endl;
cout << "you lost " << hplost << " hit points, but gain " << "5" << " life back from a potion the goblin had." << endl;
cout << "you have gained " << exp << "/" << nextlevel << " till your next level." << endl;
cout << "you have gained " << goblingp << " GP from the goblin. Your GP is at " << gp << "." << endl << endl;
getch();
gameplaychoice ( hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, 20, 20, 5, 20, "Goblin Warrior", nextlevel, maxhp, "large stick with a sharp rock tied to the end of it", blocked, level, "Falador");
//display a:\battle340.jpeg here
cout << "Goblin Warlord: I hear you have been harrassing my goblin troops!" << endl;
cout << "Abdazar: yeah i have been training with your troops, but i haven't been " << endl << "Harrassing them!" << endl;
cout << "Goblin Warlord: That's not the way I heard it, prepare yourself for revenge!" << endl;
cout << "Abdazar: Alright if it is a battle you want, a battle you shall have." << endl;
blocked = 0;
nextlevel = nextlevel + 200;
fight (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, 200, 200, 14, 200, "Goblin Warlord", nextlevel, maxhp, "A Gothic Ancents Axe" , blocked, level);
cout << "The Goblin Warlord in, return for mercy, gives you the Ring of Agility!" << endl << endl;
cout << "As you slowly slide the ring over your knuckle, you seem to notice " << endl << "things a little faster and react with better timeing." << endl << endl;
cout << "your agility level has risen by 3 points!!!" << endl;
getch();
cout << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl;
int draynorquestnumber = 0;
town ("Falador", hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, maxhp, level, 1, draynorquestnumber);
mciSendString("stop C:\\town.mid",NULL,0,NULL);
mciSendString("play C:\\lndnchip.mid",NULL,0,NULL);
}
getch ();
//mciSendString("stop C:\\lndnchip.mid",NULL,0,NULL);
//mciSendString("stop C:\\town.mid",NULL,0,NULL);
}
return 0;
}
void fight (int & hp, int & gp, int & exp, int & agilitylvl, int & lvl1potions, int & lvl2potions, int & lvl3potions, int & demonpotions, int & dammage, int & def, int chp, int cgp, int cdammage, int cexp,char *name, int & nextlevel, int & maxhp, char *nextweapon, int & blocked, int & level)
{
int choice;
int blockyesno;
int attackedxtimes=0;
if (exp >= nextlevel) {
cout << "you have gained enough expierience to level up!!!" << endl << endl;
exp = 0;
nextlevel = nextlevel*2;
maxhp = maxhp * 1.5;
def = def + 3;
hp = maxhp;
agilitylvl++;
level++;
dammage = dammage+5;
cout << "your max hp is now " << maxhp << endl;
cout << "your defense is now " << def << endl;
cout << "your agility level is now " << agilitylvl << endl;
cout << "you find a new weapon on " << name << ". you decide to use this instead of your old weapon." << endl;
cout << "your weapon shall now be a " << nextweapon << endl << endl;
level++;
return;
}
if (chp || hp <=0){
return;
}
cout << "what should i do?" << endl << endl;
cout << "1: Attack" << endl;
cout << "2: Use potion" << endl;
cout << "3: Attempt to block" << endl;
cin >> choice;
if (choice == 1){
attackedxtimes++;
if (attackedxtimes != 2 &&attackedxtimes != 5){
if (attackedxtimes != 3 && attackedxtimes != 6){
attack (hp, dammage, def, chp, cdammage, name, gp, cgp, nextlevel, exp, cexp, maxhp);
if (chp && hp > 0){
fight (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, chp, cgp, cdammage, cexp, name, nextlevel, maxhp, nextweapon, blocked, level);
}
}
}
if (attackedxtimes == 2 || attackedxtimes == 5) {
attack (hp, dammage, def, chp, cdammage, name, gp, cgp, nextlevel, exp, cexp, maxhp);
if (chp && hp > 0){
fight (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, chp, cgp, cdammage, cexp, name, nextlevel, maxhp, nextweapon, blocked, level);
}
cout << name << " apears to be getting ready for some sort of special attack." << endl << endl;
}
if (attackedxtimes == (3 || 6)) {
cdammage = cdammage*2;
attack (hp, dammage, def, chp, cdammage, name, gp, cgp, nextlevel, exp, cexp, maxhp);
cdammage = cdammage/2;
if (chp && hp > 0){
fight (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, chp, cgp, cdammage, cexp, name, nextlevel, maxhp, nextweapon, blocked, level);
}
}
}
else if (choice == 2){
usepotion (lvl1potions, lvl2potions, lvl3potions, demonpotions, hp, name, maxhp);
if (chp && hp > 0){
fight (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, chp, cgp, cdammage, cexp, name, nextlevel, maxhp, nextweapon, blocked, level);
}
}
else if (choice == 3){
blockyesno = rand() % 100 + 1;
if (blockyesno <= (agilitylvl*10)){
cout << "all dammage was successfully blocked this turn!" << endl << endl;
cout << "Abdazar" << " " << name << endl;
cout << hp << " " << chp << endl << endl;
blocked++;
fight (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, chp, cgp, cdammage, cexp, name, nextlevel, maxhp, nextweapon, blocked, level);
getch();
}
else if (blockyesno >= ((agilitylvl*10)+1)){
cout << "you accedentally take a wrong step as you attempt to block and still take" << endl <<" dammage."<< endl << endl;
hp = hp - cdammage;
cout << "Abdazar" << " " << name << endl;
cout << hp << " " << chp << endl << endl;
getch();
fight (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, chp, cgp, cdammage, cexp, name, nextlevel, maxhp, nextweapon, blocked, level);
}
}
}
void usepotion (int & lvl1potions, int & lvl2potions, int & lvl3potions, int & demonpotions, int & hp, char *name, int maxhp)
{
int potionchoice;
if (lvl1potions == 0 && lvl2potions == 0 && lvl3potions == 0 && demonpotions == 0) {
cout << "you have no potions, quick pick a battle move before " << name << " attacks you!" << endl;
return ;
}
cout << "Use which potion?" << endl << endl;
if (lvl1potions >= 1) {
cout << "1: level 1 potion" << endl;
}
if (lvl2potions >= 1){
cout << "2: level 2 potion" << endl;
}
if (lvl3potions >= 1) {
cout << "3: level 3 potion" << endl;
}
if (demonpotions >= 1) {
cout << "4: Demonic potion" << endl;
}
cin >> potionchoice;
if (potionchoice == 1) {
lvl1potions = lvl1potions-1;
hp = hp + 20;
cout << "you have gained 20 hp, your hp is now at " << hp << endl << endl;
if (hp > maxhp ){
hp = maxhp;
}
}
else if (potionchoice == 2) {
lvl2potions = lvl2potions - 1;
hp = hp + 30;
cout << "you have gained 30 hp, your hp is now at " << hp << endl << endl;
if (hp > maxhp ){
hp = maxhp;
}
}
else if (potionchoice == 3) {
lvl3potions = lvl3potions - 1;
hp = hp + 40;
cout << "you have gained 40 hp, your hp is now at " << hp << endl << endl;
if (hp > maxhp ){
hp = maxhp;
}
}
else if (potionchoice == 4) {
demonpotions = demonpotions - 1;
hp = hp + 120;
cout << "you have gained 120 hp, you hp is now at " << hp << endl << endl;
if (hp > maxhp ){
hp = maxhp;
}
}
}
void attack (int & hp, int dammage, int def, int & chp, int cdammage, char *name, int & gp, int cgp, int & nextlevel, int & exp, int cxp, int maxhp)
{
int hplost;
hplost = hp + def;
chp = chp - dammage;
int won;
if (chp <= 0 ) {
won = 1;
cout << "You are victorious!!!" << endl << endl;
exp = exp + cxp;
hplost = hplost - hp;
hp = hp + cdammage;
gp = gp + cgp;
cout << "you lost " << hplost << " hit points, but gain " << cdammage << " life back from a potion the " << name << " had." << endl;
cout << "your Hit points are now at " << hp << "." << endl;
cout << "you have gained " << exp << "/" << nextlevel << " till your next level." << endl;
cout << "you have gained " << cgp << " GP from the " << name << ". Your GP is at " << gp << "." << endl << endl;
return;
}
hp = hp - cdammage;
if (hp <= 0 ) {
hplost = hplost - hp;
cout << "you have " << exp << "/" << nextlevel << " till your next level." << endl;
cout << "you have gained 0 " << " GP from the " << name << " Your GP is at " << gp << "." << endl << endl;
cout << "the " << name << " shows you great mercy and spares your life. Your life is now at " << maxhp << "." << endl;
hp = maxhp;
return;
}
if (won == 1) {
hp = hp + cdammage;
}
cout << "Abdazar" << " " << name << endl;
cout << hp << " " << chp << endl << endl;
}
void gameplaychoice (int & hp, int & gp, int & exp, int & agilitylvl, int & lvl1potions, int & lvl2potions, int & lvl3potions, int & demonpotions, int & dammage, int & def, int chp, int cgp, int cdammage, int cexp,char *name, int & nextlevel, int & maxhp, char *nextweapon, int & blocked, int & level, char *town)
{
int attackedmonsters=0;
int choice;
cout << "What would you like to do now then?" << endl << endl;
if (attackedmonsters < 5){
cout << "1: Look for a training partner." << endl;
}
cout << "2: Goto " << town << "." << endl;
cout << "3: Quit game" << endl << endl;
cin >> choice;
if (choice == 1){
attackedmonsters++;
fight (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, chp, cgp, cdammage, cexp, name, nextlevel, maxhp, nextweapon, blocked, level);
gameplaychoice (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, chp, cgp, cdammage, cexp, name, nextlevel, maxhp, nextweapon, blocked, level, town);
}
else if (choice == 2){
return;
}
else if (choice == 3){
mciSendString("stop C:\\lndnchip.mid",NULL,0,NULL);
mciSendString("stop C:\\town.mid",NULL,0,NULL);
exit(0);
}
}
void town(char *townname, int & hp, int & gp, int & exp, int & agilitylvl, int & lvl1potions, int & lvl2potions, int & lvl3potions, int & demonpotions, int & dammage, int & def, int & maxhp, int & level, int townnumber, int & draynorquestnumber)
{
cout << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl;
//mciSendString("stop C:\\lndnchip.mid",NULL,0,NULL);
//mciSendString("play C:\\town.mid",NULL,0,NULL);
int choice;
cout << " |--------------| " << endl;
cout << " | Bank of |\\ " << endl;
cout << " | Solum | \\ " << endl;
cout << " |--------------| | |---| | | " << endl;
cout << " | Apothecary |\\ | |-|-| | | " << endl;
cout << " | | \\ | |---| | | " << endl;
cout << " | | | | |---| | | " << endl;
cout << " /-----------| | | /--------| |-|-| | |-------------\\ " << endl;
cout << " / | | |/ | |---| | |Blue Moon /\\ " << endl;
cout << " / | | / | |---| | | Inn / \\ " << endl;
cout << "/______________| _________ | |__________| |-|-| | |___________/ \\" << endl;
cout << "| |---| | | __ | __ | | | |---| | |---| | | |---|| |" << endl;
cout << "| |-|-| | |(__)|(__)| | | |-|-| | | |-----||-|-|| |" << endl;
cout << "| |---| |---|| |(__)|(__)| | | |---| | |-----| | | o|o ||---|| |" << endl;
cout << "| |+ || | 0|0 | | |__________| | | | | |_____|_____|____|" << endl;
cout << "|_________|___||_|____|____|__|/ |____|__|__|___|_| " << endl;
cout << "Welcome to " << townname << "!!!" << endl << endl;
cout << "what would you like to do now then?" << endl;
cout << "1: Rest at the local Inn and continue one my journey." << endl;
cout << "2: Visit the local Apothecary for potions." << endl;
cout << "3: Go visit with the local towns people." << endl;
cout << "4: Quit game." << endl;
cin >> choice;
if (choice == 1){
cout << "As you slowly drift into that unreal yet very believable realm of sleep" << endl << "images of a man in red robes reaking havock on the world" << endl << "flash infront of your face." << endl;
cout << "Images of complete death and destruction that follows him as he slowly," << endl << "unswayingly, and almost hypnoticly floats through the mortal world." << endl << endl;
cout << "you awaken in a cold sweat panting in the brightness of the new day discarding" << endl << "the dream as nothing more than a nightmare." << endl << endl;
getch();
return;
}
else if (choice == 2){
//mciSendString("play C:\\town.mid",NULL,0,NULL);
apothecary (lvl1potions, lvl2potions, lvl3potions, demonpotions, hp, maxhp, gp);
town (townname, hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, maxhp, level, townnumber, draynorquestnumber);
}
/*
else if (choice == 3){
if (townnumber == 1) {
questone ();
town (townname, hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, maxhp, level, townnumber, draynorquestnumber);
}
else if (townnumber == 2) {
questtwo ();
town (townname, hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, maxhp, level, townnumber, draynorquestnumber);
}
else if (townnumber == 3) {
questthree ();
town (townname, hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, maxhp, level, townnumber, draynorquestnumber);
}
else if (townnumber == 4) {
if (draynorquestnumber != 2) {
questfour ();
town (townname, hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, maxhp, level, townnumber, draynorquestnumber);
}
else if (draynorquestnumber == 2) {
questfive ();
town (townname, hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, maxhp, level, townnumber, draynorquestnumber);
}
}
}
*/
else if (choice == 4){
//mciSendString("stop C:\\lndnchip.mid",NULL,0,NULL);
//mciSendString("stop C:\\town.mid",NULL,0,NULL);
exit(0);
}
}
void apothecary (int & lvl1potions, int & lvl2potions, int & lvl3potions, int & demonpotions, int & hp, int maxhp, int & gp)
{
mciSendString("play C:\\town.mid",NULL,0,NULL);
int choice;
int cost;
cout << "your gp is currently at: " << gp << endl;
cout << "you have " << lvl1potions << "level 1 potions." << endl;
cout << "you have " << lvl2potions << "level 2 potions." << endl;
cout << "you have " << lvl3potions << "level 3 potions." << endl;
cout << "your health is at " << hp << "/" << maxhp << endl << endl;
cout << "What would you like to purchase?" << endl << endl;
cout << "1: Regenerate completely (1gp per level)" << endl;
cout << "2: Purchase a level 1 potion (20gp ea.)" << endl;
cout << "3: Purchase a level 2 potion (30gp ea.)" << endl;
cout << "4: Purchase a level 3 potion (40gp ea.)" << endl;
cout << "5: Leave Apothecary." << endl;
cin >> choice;
if (choice == 1){
int cost;
cost = maxhp - hp;
if (gp < cost) {
cout << " you don't have enough money for this." << endl;
cout << " would you like to heal health as much as you can?" << endl;
cout << "1: yes" << endl;
cout << "2: no" << endl;
cin >> choice;
if (choice == 1) {
gp = gp - gp;
hp = hp + gp;
apothecary (lvl1potions, lvl2potions, lvl3potions, demonpotions, hp, maxhp, gp);
}
else if (choice == 2) {
apothecary (lvl1potions, lvl2potions, lvl3potions, demonpotions, hp, maxhp, gp);
}
}
else if (gp >= cost) {
gp = gp-cost;
hp = maxhp;
apothecary (lvl1potions, lvl2potions, lvl3potions, demonpotions, hp, maxhp, gp);
}
}
else if (choice == 2){
cost = 20;
if (gp < cost) {
cout << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl;
cout << "you don't have enough gp for this item." << endl;
cout << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl;
getch();
apothecary (lvl1potions, lvl2potions, lvl3potions, demonpotions, hp, maxhp, gp);
}
else if (gp >= cost){
gp = gp - 20;
lvl1potions++;
apothecary (lvl1potions, lvl2potions, lvl3potions, demonpotions, hp, maxhp, gp);
}
}
else if (choice == 3) {
cost = 30;
if (gp < cost) {
cout << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl;
cout << "you don't have enough gp for this item." << endl;
cout << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl;
getch();
apothecary (lvl1potions, lvl2potions, lvl3potions, demonpotions, hp, maxhp, gp);
}
else if (gp >= cost){
gp = gp - 30;
lvl2potions++;
apothecary (lvl1potions, lvl2potions, lvl3potions, demonpotions, hp, maxhp, gp);
}
}
else if (choice == 4) {
cost = 40;
if (gp < cost) {
cout << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl;
cout << "you don't have enough gp for this item." << endl;
cout << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl;
getch();
apothecary (lvl1potions, lvl2potions, lvl3potions, demonpotions, hp, maxhp, gp);
}
else if (gp >= cost){
gp = gp - 40;
lvl3potions++;
apothecary (lvl1potions, lvl2potions, lvl3potions, demonpotions, hp, maxhp, gp);
}
}
else if (choice == 5) {
return;
}
}
```