Thread: attacking sequence

  1. #1
    |<o>| <--cyclopse LouDu's Avatar
    Join Date
    Mar 2003
    Posts
    137

    attacking sequence

    Here is my code below, my problem is i have it so enemys come up as random across the large 50 x 50 grid, only problem is when you battle with one the battle iniates he takes a swing i take a swing, then it goes right back out to epxploring makeing it impossible to kill an enemy (litereally impossible), i need to have it so when you enter combat you fight till the death, then go back to exploring, here is my code below


    Code:
    #include <conio.h>
    #include <iostream>
    #include <stdlib.h>
    #include <ctime>
    #include <iomanip.h>
    
        int RandInt(int a,int b)
    {
       return a + rand() % (b - a + 1);
    }
    
    int User_Health = 400;
    int User_Max_Health = 400;
    int User_Level = 1;
    int User_Potions = 10;
    int User_Exp = 0;
    int Next_Level = 300;
    int User_Gold = 0;
    int User_Attack;
    int name;
    
    int Q = 0;
    int USE_POTION;
    int Y;
    
    int User_Location_X = 0;
    int User_Location_Y = 0;
    int chalace = 0;
    int septor = 0;
    int end_game = 100;
    
    char input;
    
    int knight_Health = 200;
    int knight_Max_Health = 200;
    int knight_Gold = 60;
    int knight_Exp = 60;
    
    
    
    
    
    
    
    int main()
    {
    cout << "overview test";
    getch();
    system("cls");
    
    
    do
    {
    
    system ("cls");
    
    if(User_Exp >= Next_Level)
    {
    Next_Level = Next_Level * 2;
    User_Max_Health = User_Max_Health + 20;
    User_Level = User_Level++;
    User_Health = User_Max_Health;
    }
    srand(time(NULL));                   
    int Potion_Heal = RandInt(70,160);
    
    srand(time(NULL));
    int x = RandInt(1, 100);
    
    srand(time(NULL));
    int knight_Attack = RandInt(12,20);
    
    srand(time(NULL));
    int User_Attack = RandInt(15,42);
    
    srand(time(NULL));
    int knight_Exp = RandInt(30,90);
    
    srand(time(NULL));
    int knight_Gold = RandInt(1,3);
    
    
            User_Attack = (User_Attack * User_Level) * 2;
            cout << "-----------------------------------------------------\n";
            cout << "Ludlow                 To Test Your Wits and Strength\n\n";
            cout << "\nLeaving the gates of Ludlow, the guards surround the \n";
            cout << "land, you will die unless you fight for survivol. Slay \n";
            cout << "the Black Knights and collect the 15 jewls lost across\n";
            cout << "the land and return to Ludlow, to the Impeareal Guard.\n\n";
            cout << "Attack   =  A      Quit  =  Q\n\n";
    
            cout << "Health: " << User_Health << "/" << User_Max_Health << "    Level: " << User_Level << "\n";
            cout << "Exp: "<<User_Exp<<"             Exp to next level: "<<Next_Level<<"\n";
            cout << "Gold: "<<User_Gold<<"            Potions: "<<User_Potions << "\n";
            cout << "-----------------------------------------------------\n";
    
    
    	if (User_Location_Y == 50)
    	{
    		cout <<"You have reached the valley wall\n";
    		User_Location_Y = User_Location_Y--;
    		getch();
    	}
    
    	else if (User_Location_Y == -50)
    	{
    		cout <<"You have reached the valley wall\n";
    		User_Location_Y = User_Location_Y++;
    		getch();
    	}
    
    	else if (User_Location_X == 50)
    	{
    		cout <<"You have reached the valley wall\n";
    		User_Location_X = User_Location_X--;
    		getch();
    	}
    
    	else if (User_Location_X == -50)
    	{
    		cout <<"You have reached the valley wall\n";
    		User_Location_X = User_Location_X++;
    	}
    
    	end_game = end_game--;
    
    	if (end_game == 0)
    	{
    
    		system("cls");
    		cout <<"You have used all your energy, GAME OVER!\n";
    		return 0;
    	}
    
            
    	cout <<"         North (8)                        " << User_Location_X << "/50   " << User_Location_Y << "/50\n";
            cout <<"East (4)           West (6)\n";
            cout <<"         South (2)\n";
            cout <<"\n";
            
    	cin >>input;
    	cout <<"\n";
    
    	//Defines user keys
    
    	if (input == 'Q' || input == 'q')
    	{
    		system("cls");
    		cout <<"You have died in combat Warrior.\n";
    		return 0;
    	}
    
    	//Updates user position
    
    	if (input == '8')
    	{
    		User_Location_Y = User_Location_Y++;
    	}
    
    	else if (input == '2')
    	{
    		User_Location_Y = User_Location_Y--;
    	}
    
    	else if (input == '6')
    	{
    		User_Location_X = User_Location_X++;
    	}
    
    	else if (input == '4')
    	{
    		User_Location_X = User_Location_X--;
    	}
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
            //directinal code
    
    	if (User_Location_X == -29 && User_Location_Y == 41)
    	{
    		if (chalace == 1)
    		{
    			cout <<"You have found The Ethereal Chalace.\n\n";
                            getch();
    			User_Location_X = 0;
    			User_Location_Y = 0;
    		
    		}
    
    		else if (chalace == 0)
    		{
    			cout <<"You have found The Ethereal Chalace.\n\n";
    			chalace = 1;
                            User_Exp = User_Exp +10;
    			User_Gold = User_Gold + 75;
                            cout << "You have recieved " << User_Gold << " gold pieces, " << User_Exp << " Exp & The Ethereal Chalace.";
    			getch();
                            User_Location_X = 0;
    			User_Location_Y = 0;
    		}
    	}
    
    	if (User_Location_X == 21 && User_Location_Y == 20)
    	{
    		if (septor == 1)
    		{
    			cout <<"You have found a Golden Septor Of The Lord.\n\n";
                            getch();
    			User_Location_X = 0;
    			User_Location_Y = 0;
    		}
    
    		else if (septor == 0)
    		{
    			cout <<"You have found a Golden Septor Of The Lord.\n\n";
    			septor = 1;
                            User_Exp = User_Exp +21;
    			User_Gold = User_Gold + 15;
                            cout << "You have recieved " << User_Gold << " gold pieces, " << User_Exp << " Exp & The Golden Septor Of The Lord.";
                            getch();
    			User_Location_X = 0;
    			User_Location_Y = 0;
    		}
    	}
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
            //Battleing with the black kngiht
    
            if (x > 90)
            {
                    cout << "You Have entered combat with a Black Knight\n\n";
                    cout << "\nBlack Knight attacks, does "<<knight_Attack<<" Damage.\n";
                    User_Health = User_Health - knight_Attack;
                    getch();
    
            if (User_Health >=1)
                    cout << "\nYou attack, and do " <<User_Attack<<" damage.\n\n";
                   knight_Health = knight_Health - User_Attack;
                   getch();
    
            if(User_Health <= 0)
            {
                    User_Health = 0;
                    cout << "\nYou have been slayed in battle!\n";
                    cout << "Press any key to continue...\n";
                    getch();
                    return 0;
             }
            if(knight_Health <= 0)
            {
            cout << "\nYou have defeated a Black Knight.\n";
            cout << "You gain "<< knight_Exp << " Exp and "<<knight_Gold<<" Gold.\n";
            getch();
    
            User_Exp = User_Exp + knight_Exp;
            User_Gold = User_Gold + knight_Gold;
            knight_Health = knight_Max_Health;
    
    
    
            if(User_Potions == 1)
            {
    
            User_Potions = User_Potions++;
            cout << "You found a potion\n";
            getch();
            system ("cls");
            }
    
            cout << "\nDo you wish to use a potion?\n1)Yes 2)No\n";
            cin >> USE_POTION;
    
            if(USE_POTION == 1 & User_Potions >= 1)
            {
            system ("cls");
    
            cout << "You have been healed for "<<Potion_Heal<<"\n";
    
            User_Potions = User_Potions--;
    
            User_Health = User_Health + Potion_Heal;
            if(User_Health >= User_Max_Health)
            {
            User_Health = User_Max_Health;
            }
            }
            }
            else
            {
            }
            }
            }
            while(end_game!=1);
    
    	return 0;
    }

  2. #2
    |<o>| <--cyclopse LouDu's Avatar
    Join Date
    Mar 2003
    Posts
    137
    this still dose not help my problem.

    I engage in battle at random places, that works fine, i throw a swing he throwns a swing, but then you do not continue the battle till someone dies.

    i need it so you do finish the battle, then you move aorund using the directonial keys.
    Languages <> C++, HTML

    /*The Ledgend of Ludlow Coming to a PC Near
    You intro Cinenmatic Needed email me of
    Reply to one of my threads if you can make
    one, thats decent. */

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    2
    a do while perhaps?


    code:
    do

    {
    cout << "\nBlack Knight attacks, does "<<knight_Attack<<" Damage.\n";
    User_Health = User_Health - knight_Attack;
    getch();

    if (User_Health >=1)
    cout << "\nYou attack, and do " <<User_Attack<<" damage.\n\n";
    knight_Health = knight_Health - User_Attack;
    getch();

    }
    while ( User_Health >=1 || knigh_Health >=1);

    end code:

    in this case you would just keep attacking tell one charcter is dead.
    Last edited by AdamantiumWulf; 03-10-2003 at 03:17 PM.

  4. #4
    |<o>| <--cyclopse LouDu's Avatar
    Join Date
    Mar 2003
    Posts
    137
    sru but thanks it was fixed abotu a week ago by a firend who helped me it was just a simple error i missed
    Languages <> C++, HTML

    /*The Ledgend of Ludlow Coming to a PC Near
    You intro Cinenmatic Needed email me of
    Reply to one of my threads if you can make
    one, thats decent. */

  5. #5
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Originally posted by LouDu
    sru but thanks it was fixed abotu a week ago by a firend who helped me it was just a simple error i missed
    [loudu impression]

    omg dont you know anything?? How can you miss an error!! It was so simple like you are such a $$$$ing newb god you suck go learn some VB poser.

    [/loudu impression]

  6. #6
    |<o>| <--cyclopse LouDu's Avatar
    Join Date
    Mar 2003
    Posts
    137
    :P, but see the difeeence is that i post it once bliazzard dog posts it then replys 5 times till someone anwsers
    Languages <> C++, HTML

    /*The Ledgend of Ludlow Coming to a PC Near
    You intro Cinenmatic Needed email me of
    Reply to one of my threads if you can make
    one, thats decent. */

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Immediate programming help! Please!
    By xMEGANx in forum C++ Programming
    Replies: 6
    Last Post: 02-20-2008, 12:52 PM
  2. sequence
    By braddy in forum C Programming
    Replies: 2
    Last Post: 03-30-2006, 02:15 PM
  3. wsprintf and format specifiers
    By incognito in forum Windows Programming
    Replies: 2
    Last Post: 01-03-2004, 10:00 PM
  4. How do I restart a random number sequence.
    By jeffski in forum C Programming
    Replies: 6
    Last Post: 05-29-2003, 02:40 PM
  5. %i or %d - where is the difference?
    By Sargnagel in forum C Programming
    Replies: 3
    Last Post: 11-12-2002, 03:21 PM