Help on 2D D&D game, almost done!

Help on 2D D&D game, almost done!

Page 1 of 1

11 Replies - 2157 Views - Last Post: 29 April 2009 - 07:13 AM Rate Topic: -----

#1 codecsmash49  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 61
  • Joined: 09-December 08

Help on 2D D&D game, almost done!

Post icon  Posted 26 April 2009 - 08:05 PM

I am almost finished with my game. I am using VC++

I keep getting the error codes

c:\documents and settings\administrator\desktop\d_final\data.cpp(83) : error C2601: 'buildMasterLists' : local function definitions are illegal

1> c:\documents and settings\administrator\desktop\d_final\data.cpp(7): this line contains a '{' which has not yet been matched

1>c:\documents and settings\administrator\desktop\d_final\data.cpp(203) : fatal error C1075: end of file found before the left brace '{' at 'c:\documents and settings\administrator\desktop\d_final\data.cpp(7)' was matched

This is a pretty big code project. Would there be an easy way to show my code for help?

Is This A Good Question/Topic? 0
  • +

Replies To: Help on 2D D&D game, almost done!

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6078
  • View blog
  • Posts: 23,546
  • Joined: 23-August 08

Re: Help on 2D D&D game, almost done!

Posted 26 April 2009 - 08:23 PM

Sounds like you've started a function definition within another function definition.

Show us about 20 lines from data.cpp starting from line 75.
Was This Post Helpful? 0
  • +
  • -

#3 codecsmash49  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 61
  • Joined: 09-December 08

Re: Help on 2D D&D game, almost done!

Posted 26 April 2009 - 08:32 PM

Here is the brief spot of the code

Data.cpp

void buildMasterTriggerList ()
{
#ifdef DEBUG_BUILD
	cerr << "DEBUG: Building Master Trigger List" << endl;
#endif
	// always clear the list first
	clearMasterTriggerList ();

	addTrigger (createTrigger (trigger_story_1, 36, 39, WEST_HASHBURG, DisableAutoOff));
	addTrigger (createTrigger (trigger_story_2, 35, 39, WEST_HASHBURG, DisableAutoOff));
	addTrigger (createTrigger (trigger_story_3, 11, 51, WEST_HASHBURG, DisableAutoOff));

	addWarp (WEST_HASHBURG, 62, 36, EAST_HASHBURG, 11, 36); 
	addWarp (WEST_HASHBURG, 62, 38, EAST_HASHBURG, 11, 38); 
	addWarp (WEST_HASHBURG, 62, 40, EAST_HASHBURG, 11, 40); 



	// EAST
	addTrigger (createTrigger (trigger_inn, 34, 34, EAST_HASHBURG, DisableAutoOff));
	addTrigger (createTrigger (trigger_shop, 51, 50, EAST_HASHBURG, DisableAutoOff));
	addTrigger (createTrigger (trigger_locked_door, 54, 60, EAST_HASHBURG, DisableAutoOff));
	addTrigger (createTrigger (trigger_locked_door, 58, 32, EAST_HASHBURG, DisableAutoOff));

	addWarp (EAST_HASHBURG, 8, 36, WEST_HASHBURG, 59, 36); 
	addWarp (EAST_HASHBURG, 8, 38, WEST_HASHBURG, 59, 38); 
	addWarp (EAST_HASHBURG, 8, 40, WEST_HASHBURG, 59, 40); 

	addWarp (EAST_HASHBURG, 32, 62, LVL1, 15, 15); 
	addWarp (EAST_HASHBURG, 34, 62, LVL1, 15, 15); 
	addWarp (EAST_HASHBURG, 36, 62, LVL1, 15, 15); 

	// WORLD MAP

	addWarp (LVL1, 12,  9, EAST_HASHBURG, 34, 58);
	addWarp (LVL1, 14,  9, EAST_HASHBURG, 34, 58);
	addWarp (LVL1, 14, 11, EAST_HASHBURG, 34, 58);
	addWarp (LVL1, 14, 13, EAST_HASHBURG, 34, 58);
	addWarp (LVL1, 12, 14, EAST_HASHBURG, 34, 58);
	addWarp (LVL1, 10, 11, EAST_HASHBURG, 34, 58);


	addWarp (LVL1, 14, 28, NORTH_LVL2, 34, 12);
	

	
	addTrigger (createTrigger (trigger_cave_in, 11, 57, NORTH_LVL2));
	addTrigger (createTrigger (trigger_cave_in, 58, 55, NORTH_LVL2));
	addTrigger (createTrigger (trigger_cave_in, 31, 17, NORTH_LVL2));

	addWarp (NORTH_LVL2, 33, 61, BigBoss, 35, 12);




void buildMasterLists ()
{
	// include the master item list

// MAP_ITEM (alias, index);

 #ifdef DEBUG_BUILD
  cerr << "DEBUG: Building Master Item List" << endl;
 #endif
 
 MAP_ITEM (Bandage,					 0);
 MAP_ITEM (Tea,						 1);
 MAP_ITEM (Brimstone,				   2);
 MAP_ITEM (Birthwart,				   3);


// MAP_EQUIPMENT (alias, index);


 #ifdef DEBUG_BUILD
  cerr << "DEBUG: Mapping equipment" << endl;
 #endif 
 
 MAP_EQUIPMENT (Leather Armor,		  20); 
 MAP_EQUIPMENT (Black Robe,			 22);
 MAP_EQUIPMENT (Blue Robe,			  24); 
 MAP_EQUIPMENT (Dusk Amulet,			26); 
 MAP_EQUIPMENT (Dawn Amulet,			28); 
 MAP_EQUIPMENT (Hell Amulet,			30); 


// ADD_ITEM (alias, method_name, category); 

 #ifdef DEBUG_BUILD
  cerr << "DEBUG: Adding items" << endl;
 #endif
 
 ADD_ITEM (Bandage,					 Bandage, eUsable);
 ADD_ITEM (Tea,						 Tea, eUsable);
 ADD_ITEM (Brimstone,				   Brimstone, eStory);
 ADD_ITEM (Birthwart,				   Birthwart, eStory);

// ADD_EQUIPMENT (alias, method_name, pha, phd, maa, mad, type);


 #ifdef DEBUG_BUILD
  cerr << "DEBUG: Adding equipment" << endl;
 #endif
  
 ADD_EQUIPMENT (Leather Armor,		  LeatherArmor, 0,10, 0, 0, eArmor);
 ADD_EQUIPMENT (Blue Robe,			  BlueRobe,	 0, 0, 0,10, eArmor);
 ADD_EQUIPMENT (Black Robe,			 BlackRobe,	0, 0,10, 0, eArmor);
 ADD_EQUIPMENT (Dusk Amulet,			DuskAmulet,   0,10, 0,10, eAccessory);
 ADD_EQUIPMENT (Dawn Amulet,			DawnAmulet,   5, 5, 5, 5, eAccessory);
 ADD_EQUIPMENT (Hell Amulet,			HellAmulet,  10, 0,10, 0, eAccessory);
  
 
 
// include the master ability list

// MAP_ABILITY (alias, index);
 
 #ifdef DEBUG_BUILD
  cerr << "DEBUG: Building Master Ability List" << endl;
 #endif
 
 #ifdef DEBUG_BUILD
  cerr << "DEBUG: Mapping abilities" << endl;
 #endif
  
 MAP_ABILITY (Attack,				   0); 
 MAP_ABILITY (Ferocious Strike,		 1); 
 MAP_ABILITY (Heal,					 2); 

// ADD_ABILITY (alias, method_name); 
 

 #ifdef DEBUG_BUILD
  cerr << "DEBUG: Adding abilities" << endl;
 #endif 

 ADD_ABILITY (Attack,				   poa_Attack);
 ADD_ABILITY (Ferocious Strike,		 poa_FerociousStrike);
 ADD_ABILITY (Heal,					 poa_Heal);
 
	// fill the master enemy list
	buildMasterEnemyList ();

#ifdef DEBUG_BUILD
	cerr << "DEBUG: Creating Game World" << endl;
#endif 


	pushMaps (52, world_map,
		w_zular, e_zular,
		nw_balmant, n_balmant, ne_balmant,
		sw_balmant, s_balmant, se_balmant,
		radnine_crag,
		);


	// define the map terrain data types 
	addMapData (createMapData (SPACE_WALL,	"WALL",	"WALL",	eMapIsSafe,	eMapIsNotPassable));
	addMapData (createMapData (SPACE_SWAMP,   "Swamp",   "Swamp",   eMapIsNotSafe, eMapIsPassable));
	addMapData (createMapData (SPACE_INDOORS, "Indoors", "Indoors", eMapIsSafe,	eMapIsPassable));
	addMapData (createMapData (SPACE_SAND,	"Sand",	"Sand",	eMapIsNotSafe, eMapIsPassable));
	addMapData (createMapData (SPACE_GRASS,   "Grass",   "Grass",   eMapIsNotSafe, eMapIsPassable));
	addMapData (createMapData (SPACE_DIRT,	"Dirt",	"Dirt",	eMapIsNotSafe, eMapIsPassable));
	addMapData (createMapData (SPACE_ROCK,	"Rock",	"Rock",	eMapIsNotSafe, eMapIsPassable));
	addMapData (createMapData (SPACE_WATER,   "Water",   "Water",   eMapIsSafe,	eMapIsNotPassable));
	addMapData (createMapData (SPACE_BRIDGE,  "Bridge",  "Bridge",  eMapIsSafe,	eMapIsPassable));
	addMapData (createMapData (SPACE_TRIGGER, "Trigger", "Event",	   eMapIsSafe,	eMapIsPassable));



	iCurrent_map	  = WEST_HASHBURG;

	iCurrent_location = SPACE_INDOORS;

}


Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6078
  • View blog
  • Posts: 23,546
  • Joined: 23-August 08

Re: Help on 2D D&D game, almost done!

Posted 27 April 2009 - 03:47 AM

Yep, how about closing buildMasterTriggerList before starting buildMasterLists?
Was This Post Helpful? 0
  • +
  • -

#5 codecsmash49  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 61
  • Joined: 09-December 08

Re: Help on 2D D&D game, almost done!

Posted 27 April 2009 - 06:14 AM

Thank you i managed to fix it ^.^ missed a "}" -.-
Was This Post Helpful? 0
  • +
  • -

#6 codecsmash49  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 61
  • Joined: 09-December 08

Re: Help on 2D D&D game, almost done!

Posted 27 April 2009 - 06:31 AM

My program seems to keep having a constant flow of errors. Each time i correct something more show up. Is there any way to get help with debugging it
Was This Post Helpful? 0
  • +
  • -

#7 codecsmash49  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 61
  • Joined: 09-December 08

Re: Help on 2D D&D game, almost done!

Posted 27 April 2009 - 07:21 AM

ITS WORKING! But I made it so after X amount of time my hero gets tired and should need to rest. However im stuck at tired -.-
Was This Post Helpful? 0
  • +
  • -

#8 codecsmash49  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 61
  • Joined: 09-December 08

Re: Help on 2D D&D game, almost done!

Posted 27 April 2009 - 02:01 PM

I'm almost done with my 2D dungeon game, but for some reason i cannot move when my program calls to move i cannot move ever when i set the Vitality to 100 it sets it to 0. When i remove the params and make it so it will move it still cannot.

ENTITY :: ENTITY ()			  
{
	m_fpkAction	= NULL;
	m_eState	   = eNormal;
	m_strAlias	 = "Undefined";
	m_strClass	 = "Hero";
	m_iXpos		= 0; m_iYpos		= 0; m_iHp		  = 0; m_iMp		  = 0;
	m_iMaxHp	   = 0; m_iMaxMp	   = 0; m_iStrength	= 0; m_iVitality	= 0;
	m_iPhysicalAtk = 0; m_iPhysicalDef = 0; m_iMagickalAtk = 0; m_iMagickalDef = 0;
	m_iMoney	   = 0; m_iLevel	   = 0; m_iExperience  = 0; m_iSpacesMoved = 0;


string ENTITY :: getVitalString ()
{
 string vitals = ""; 
 
 if (m_iVitality >= 0 && m_iVitality <= 25)		{ vitals = "Exhausted"; }
 else if (m_iVitality >= 26 && m_iVitality <= 50)  { vitals = "Tired"; }
 else if (m_iVitality >= 51 && m_iVitality <= 100) { vitals = "Alert"; }
 else if (m_iVitality > 100)					   { vitals = "Psyched"; }
 return vitals; 
}


void ENTITY :: navigate (eMotionDirection eDir)
{
 string feedback = "";
 
 if (m_strClass != "Monster")
 {
  //ofstream output;
  //output.open("error.txt", ios::app);
  //output << "m_strClass = " << m_strClass << endl;
  //output.close();
	 feedback = m_strAlias + " is too tired to move...\n" + m_strClass;
 }
  
 if (m_iVitality > 0)
 {
  switch (eDir)
  {
   case eNorth:	{m_iYpos--;}break;
   case eSouth:	{m_iYpos++;}break;
   case eEast:	 {m_iXpos++;}break;
   case eWest:	 {m_iXpos--;}break;
   case eNorthWest:{m_iYpos--; m_iXpos--;}break;
   case eNorthEast:{m_iYpos--; m_iXpos++;}break;
   case eSouthWest:{m_iYpos++; m_iXpos--;}break;
   case eSouthEast:{m_iYpos++; m_iXpos++;}break;
  }

  if (m_iYpos < 0) m_iYpos = C_GAMEWORLD_SIZE;
  if (m_iXpos < 0) m_iXpos = C_GAMEWORLD_SIZE;
  if (m_iXpos > C_GAMEWORLD_SIZE) m_iXpos = 0;
  if (m_iYpos > C_GAMEWORLD_SIZE) m_iYpos = 0;
 }
 else
 {
  Common :: pause (center_press_return);
 }  
}



void ENTITY :: giveVitality	(int iAmount) {INC_AND_LIMIT(m_iVitality, iAmount, 255);}



void ENTITY :: takeVitality	(int iAmount) {DEC_AND_LIMIT(m_iVitality, iAmount, 0);}




Also when ever i call to display HP it comes out as 0/0 same for mana
void displayMinimap ()
{ 
	int xStart = kHero.m_iXpos - 5;
	int yStart = kHero.m_iYpos - 5;

	cout << PRINT_OFFSET; Common :: DrawBoxTop (13); cout << endl;

	for (int y = 0; y < 11; y++)
	{
		cout << PRINT_OFFSET << BoxLC;
		for (int x = 0; x < 11; x++)
		{
			if ( (x == 5) && (y == 5) )
			{
				cout << char(1);
			}
			else
			{
				cout << char (vpiMaps.at(iCurrent_map)[(yStart * 72) + xStart]);

				// handle heads up display
				if ( (x == 10) && (y == 0) )
				{
					cout << BoxRC << " " << kHero.m_strAlias;
				}
				else if ( (x == 10) && (y == 1) )
				{
					cout << BoxRC <<			" HEALTH " << setw(4) << kHero.m_iHp << setw(0) << " / " << setw(4) << kHero.m_iMaxHp;
				}
				else if ( (x == 10) && (y == 2) )
				{
					cout << BoxRC << setw(0) << " MANA   " << setw(4) << kHero.m_iMp << setw(0) << " / " << setw(4) << kHero.m_iMaxMp;
				}



Am i doing something wrong when i call it from ENTITY::ENTITY?
Was This Post Helpful? 0
  • +
  • -

#9 Zerobu  Icon User is offline

  • Black Hatter

Reputation: 13
  • View blog
  • Posts: 1,822
  • Joined: 14-January 08

Re: Help on 2D D&D game, almost done!

Posted 27 April 2009 - 02:04 PM

hey when your done with it, do you mind if I get a copy of the source code?
Thanks!
Was This Post Helpful? 0
  • +
  • -

#10 codecsmash49  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 61
  • Joined: 09-December 08

Re: Help on 2D D&D game, almost done!

Posted 27 April 2009 - 02:10 PM

View PostZerobu, on 27 Apr, 2009 - 01:04 PM, said:

hey when your done with it, do you mind if I get a copy of the source code?
Thanks!


sure if i can get it to work :( so far everything i declare doesnt pass so i cannot move
Was This Post Helpful? 0
  • +
  • -

#11 nerodamsel  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 118
  • Joined: 31-January 09

Re: Help on 2D D&D game, almost done!

Posted 27 April 2009 - 05:07 PM

hehe can i have the game I dont need a source code.. i just want to see your game..
Was This Post Helpful? 0
  • +
  • -

#12 Masterchief117.arbiter  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 159
  • Joined: 27-March 09

Re: Help on 2D D&D game, almost done!

Posted 29 April 2009 - 07:13 AM

you need to examine this code
  if ( (x == 10) && (y == 0) )
				{
					cout << BoxRC << " " << kHero.m_strAlias;
				}
				else if ( (x == 10) && (y == 1) )
				{
					cout << BoxRC <<			" HEALTH " << setw(4) << kHero.m_iHp << setw(0) << " / " << setw(4) << kHero.m_iMaxHp;
				}
				else if ( (x == 10) && (y == 2) )
				{
					cout << BoxRC << setw(0) << " MANA   " << setw(4) << kHero.m_iMp << setw(0) << " / " << setw(4) << kHero.m_iMaxMp;
				}

your using if statements to display health and mana your code suggest that when x =something y=something else im not an exp game programmer but i know that you need to have a physical health (not displayed) and a virtual health the one that shows up on screen now you don't have to do it this way but from exp playing games a( it makes it harder to cheat at and B) it will make for a smoother transition but i would ask jack of all trades kya or born 2 code as they seem to be the senior experts on c and c++ related tasks and other languages but good luck trying to figure out plz send me source though.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1