ok guys lets see if you can see what's wrong with my program i have so far. it is for a role playing game but when you choose to "attack" in the program, when i play it, it won't let me attack now. the problem would be in the gameplaychoice function i thought but can't find what's wrong (probobly a noobish problem i am new to programming) so i will post all the code i got so far incase the prob is elsewere. (don't mind the pic it isn't real good it is supposed to look like this [IMG]http://picsforforums.tripod.com/battle340.jpg[/IMG]

#pragma hdrstop
#include <condefs.h>
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>

//---------------------------------------------------------------------------
#pragma argsused
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);
void usepotion (int & lvl1potions, int & lvl2potions, int & lvl3potions, int & demonpotions, int & hp, char *name, int maxhp);
void battle (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 main(int argc, char **argv)
{
// 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 << "A role playing game by Nate Nelson" << 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){
                    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;
                        //this is where battle sounds or music is played
                        dammage = 10;
                        int goblinhp = 20;
                        int goblinexp = 20;
                        int goblingp = 20;
                        //1st attack
                        hplost = hp;
                        goblinhp = goblinhp-10;
                        hp = hp-5+2;
                        goblinhp = goblinhp-10;
                        hp = hp-5+2;
                        hplost = hplost-hp;
                        gp = gp+goblingp;
                        hp = hp+5;
                        exp = 0;
                        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 << ".                  _____'''''___                           "<< endl;
                                cout << ".               __''     ____    '_                        "<< endl;
                                cout << ".             '  +      '    ''_   '_                      "<< endl;
                                cout << ".            '  |      '        '    '                     "<< endl;
                                cout << ".       _--'   |       '        '     |                    "<< endl;
                                cout << ".     ;`      |   _ '''''_____ '    '                      "<< endl;
                                cout << ".    ;       |  _'           _'  _'                        "<< endl;
                                cout << ".   {__''```|  |          _''  '|_|                        "<< endl;
                                cout << ".          |   |    |''''| _ '                             "<< endl;
                                cout << ".        _ _''|    {_____|                                 "<< endl;
                                cout << ".        ||   |                                            "<< endl;
                                cout << ".        . '||                                             "<< endl;
                                cout << ".         ''| |       )''''''.                             "<< endl;
                                cout << ".            | |       ''_    |_                           "<< endl;
                                cout << ".             | |         |____ '''_  .                    "<< endl;
                                cout << ".              | |             |_^_ ^| |._                 "<< endl;
                                cout << ".               | |        _'''''_|__  |  |                "<< endl;
                                cout << ".                | |     _'  _   | | | |  |                "<< endl;
                                cout << ".                 | |   '  '' '  ||_|__'  '_               "<< endl;
                                cout << ".                  |_| |  '''|  |_'    ||   |              "<< endl;
                                cout << ".                     |  |  | _''       |    |             "<< endl;
                                cout << ".                     |_ |_''|._________|''__|             "<< endl;
                                cout << ".                       (  .;    '''''''|   | '            "<< endl;
                                cout << ".                       |    |^|         ..|   |'''>       "<< endl;
                                cout << ".                       |       '''''''''  '    ' '        "<< endl;
                                cout << ".                      /    | |  |  |   '   '    '__       "<< endl;
                                cout << ".                _____/    |  |  |  |    '   '   '  |      "<< endl;
                                cout << ".                '        |  |   |   |    '   '      |     "<< endl;
                                cout << ".                 '      |  |    |    '    '         /     "<< endl;
                                cout << ".                  '    '         |         '       /      "<< endl;
                                cout << ".                   '              |               /       "<< endl;
                                cout << ".                    '''_           /|      _    /         "<< endl;
                                cout << ".                        | ________/ |     / '_/           "<< endl;
                                cout << ".                                    |____/                "<< endl << endl;
                                cout << "Goblin Warlord: I hear you have been harrassing my goblin troops!" << endl << endl;
                                cout << "Abdazar: yeah i have been training with your troops, but i haven't been Harrassing them!" << endl << endl;
                                cout << "Goblin Warlord: That's not the way I heard it, prepare yourself for revenge!" << endl << endl;
                                cout << "Abdazar: Alright if it is a battle you want, a battle you shall have." << endl << endl;
                                blocked = 0;
                                battle (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, 200, 200, 14, 200, "goblin", nextlevel, maxhp, "large stick with a sharp rock tied to the end of it", blocked, level);














                }






















getch ();

        }
        return 0;
}
void battle (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);
                if (chp && hp > 0){
                    battle (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, chp, cgp, cdammage, cexp, name, nextlevel, maxhp, "large stick with a sharp rock tied to the end of it", blocked, level);
                }
            }

        }
        if (attackedxtimes == 2 || attackedxtimes == 5) {
            attack (hp, dammage, def, chp, cdammage, name, gp, cgp, nextlevel, exp, cexp);
                if (chp && hp > 0){
                    battle (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, chp, cgp, cdammage, cexp, name, nextlevel, maxhp, "large stick with a sharp rock tied to the end of it", 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);
            cdammage = cdammage/2;
                if (chp && hp > 0){
                    battle (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, chp, cgp, cdammage, cexp, name, nextlevel, maxhp, "large stick with a sharp rock tied to the end of it", blocked, level);
                }
            return;
        }
    }
    else if (choice == 2){

        usepotion (lvl1potions, lvl2potions, lvl3potions, demonpotions, hp, name, maxhp);
        if (chp && hp > 0){
        battle (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, chp, cgp, cdammage, cexp, name, nextlevel, maxhp, "large stick with a sharp rock tied to the end of it", 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++;
                battle (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, chp, cgp, cdammage, cexp, name, nextlevel, maxhp, "large stick with a sharp rock tied to the end of it", 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();
                battle (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, chp, cgp, cdammage, cexp, name, nextlevel, maxhp, "large stick with a sharp rock tied to the end of it", blocked, level);
            }

    }





}


void usepotion (int & lvl1potions, int & lvl2potions, int & lvl3potions, int & demonpotions, int & hp, char *name, int maxhp)
{

int potionchoice;
    if (lvl1potions == 0) {
        if (lvl2potions == 0){
            if (lvl3potions ==0){
                if (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 hplost;
hplost = hp + def;
chp = chp - dammage;
int won;
    if (chp <= 0 ) {
        won = 1;
        cout << "You are victorious!!!" << endl << endl;
        exp = exp + 20;
        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 ) {
        exp = exp + cxp;
        hplost = hplost - hp;
        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-cgp; << " GP from the goblin.  Your GP is at " << gp << "." << endl << endl;

        return;

        getch();
    }
            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 << endl;
cin >> choice;
    if (choice == 1){
        battle (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, chp, cgp, cdammage, cexp, name, nextlevel, maxhp, nextweapon, 0, 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;
    }


}

"Image hosted by Tripod" was the picture I got...

yeah sorry about that it is supposed to be this.

p.s. if you right click on the "image hosted by tripod" picture, and select properties, it displays the url that the picture is at (for future reference), tripod just wants to keep everything it hosts to itself i guess.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.