cout is ambigous??

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#include "Library.h"

using namespace std;

void ListMonsters(MONSTER* list,int count);
void AttackMonster(PLAYER* player,MONSTER* monster);

bool Battle(PLAYER* player,MONSTER* list,int count)
{
	while (player->GetHealth() > 0)
	{
		// player goes first
		cout << "You Clecnh Your " << player->GetWeapon()->GetName() << "tightly and face the enemy.\n\n";

		//display enemy count
		if (count == 1)
		{
			cout << "The" << list->GetName() << "stares at you, ready to attack.\n";

			Wait();
		}
		else
		{

		}

		// display player stats
		cout << player->GetName() << endl;
		//health / maxhealth. mana /maxmana
		cout << "Health" << player->GetHealth() << " / " << player->GetMaxHealth() << endl;
		cout<< "Mana" << player->GetMana() << " / " << player->GetMaxMana() << endl;
		}

		int action = 0;

		while (true)
		{
			cout << "1: Attack\n";
			cout << "2: Spell\n";
			cout << "3: Item\n";

			cout << ">";

			cin >> action;

			/*if(action == 1 || action == 2 || action == 3)
			break;*/
			//action?
			if (action == 1) // attack
			{
				// ask for target
				if(count == 1)
				{
					// attack single monster
					AttackMonster(player,list);

				}




			}
			else
			{
				// ask for target
				int target = 0;
				while (true)
				{
					ListMonsters(list,count);

					cout << "nO Cancel\n\n";

					cout << "Which Monsters?\n";
					cout << ">";

					cin >> target;
					cin.ignore(10,'\n');

					if(target > 0 && target <= count)
					{
						// check if target is alive
						if(list[target].GetHealth() > 0)
						{
							//attack the target
							AttackMonster(player,&list(choice-1))
							break;
						}
						else
						{
							cout << "Invalid monster.\n\n";
						}
					else if(target == 0)

						//cancelled attack
						action = 0;
						break;

					} //end while target chosen
				}
				
				break;
			}


			if(action == 1) // followed through with attack
			break;
		}
			else if (action == 2) // spell
			{
				// display players spells
				break;
			}
			else if (action == 3) //item
			{
				// display players items
				break;
			}

	}


	//check action

	// is enemy dead?

	//enemies turn

	if (count == 1)
	{
		// have enemy fight
	}
	else
	{
		// loop
		for (int loop = 0; loop < count; loop++)
		{
			// list[loop]
		}
	}



		cout << " Thou hast been destroyed.\n\n";
		}
		return false; // you died
}

void ListMonsters(MONSTER* list, int count)
{
	cout << "Enemies\n";
	for (int loopname = 0; loopname < count; loopname++)
	{
		if(list[loopname].GetHealth() > 0)
		{
			cout << loopname+1 << ": " << list[loopname].GetName();

			// output status effect
			// goblin - poisoned
		}
	}

	Wait();

}

void AttackMonster(PLAYER* player,MONSTER* monster)
{


	/* 
	Damage Taken = ATT - AP
	Damage Given = ((Att+Strength) / 2) TO (ATT+Strength) WITH (10-Strength) % Chance miss 
	*/

	// calculate miss?
	if (player->GetStrength()  < 10)
	{
		//generate random number
		int random = (rand()% (10-player->GetStrength()))+1;

		if(random == 1) // miss
		{
			cout <<" You swing as hard as you can but missed horribly\n";
			break;
		}

		// attack single monster

		int pstr = player->GetStrength(); // player strength
		int damagelow = ((player->GetWeapon()->GetDamage()+pstr) / 2);
		int damagehigh = (player->GetWeapon()->GetDamage()+pstr);

		// generate damage
		int damagegiven = (rand()%damagehigh- damagelow)+damagelow;
		int totaldamage = damagegiven - monster->GetArmor();

		cout << "You injure the" << monster->GetName() << "for " << totaldamage << "health";
		monster->LoseHealth(totaldamage);
	}
}


my code is a little sloppy right now because i moved my while into its own function
i HAVE included using namespace std;

in my library.h

1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
using namespace std;

#include "Items.h"
#include "Armor.h"
#include "Weapons.h"

#include "Entity.h"
#include "Monster.h"
#include "Player.h"

#include "Globals.h" 



all the errors im getting are intellisense errors... .

if someone could point me in the right direction it would be greatly appreciated
Last edited on
You didn't tell us what the errors are or what lines they're on. In fact, you didn't even tell us there was a problem. All you did was paste a giant glob of text. What kind of response were you looking for?

To answer your question: no, cout is not ambiguous. It's quite well defined.

all the errors im getting are intellisense errors... .


If it's compiling without error then your code is fine.

If there are intellisense errors in code that compiles OK, then something is wrong with the intellisense.

I wouldn't worry about it.
lol there's 41 errors here they are.....

38 IntelliSense: this declaration has no storage class or type specifier c:\users\x d y n a s 7 y\desktop\afternoon\runes of sarnac 2.0\runes of sarnac 2.0\battle.cpp 202

34 IntelliSense: identifier "pstr" is undefined c:\users\x d y n a s 7 y\desktop\afternoon\runes of sarnac 2.0\runes of sarnac 2.0\battle.cpp 195

33 IntelliSense: identifier "player" is undefined c:\users\x d y n a s 7 y\desktop\afternoon\runes of sarnac 2.0\runes of sarnac 2.0\battle.cpp 195

37 IntelliSense: identifier "monster" is undefined c:\users\x d y n a s 7 y\desktop\afternoon\runes of sarnac 2.0\runes of sarnac 2.0\battle.cpp 200

25 IntelliSense: expression must have (pointer-to-) function type c:\users\x d y n a s 7 y\desktop\afternoon\runes of sarnac 2.0\runes of sarnac 2.0\battle.cpp 90


anyways alot of them are cout is ambigous and alot more of these are repeated... if you want i can zip the .sin and you can take a look at the whole thing because there's about 10 or 12 headers/cpp files...
Last edited on
Well again.... those are intellisense errors, so they don't matter.

If the code is compiling ok then there's no problem. Don't worry about it. It's just your intellisense being dumb.

Maybe try cleaning the solution and rebuilding.
it doesent build....


Error 11 error C2447: '{' : missing function header (old-style formal list?) c:\users\x d y n a s 7 y\desktop\afternoon\runes of sarnac 2.0\runes of sarnac 2.0\battle.cpp 154

Error 4 error C2181: illegal else without matching if c:\users\x d y n a s 7 y\desktop\afternoon\runes of sarnac 2.0\runes of sarnac 2.0\battle.cpp 97

Error 5 error C2181: illegal else without matching if c:\users\x d y n a s 7 y\desktop\afternoon\runes of sarnac 2.0\runes of sarnac 2.0\battle.cpp 113

Error 3 error C2143: syntax error : missing ';' before 'break' c:\users\x d y n a s 7 y\desktop\afternoon\runes of sarnac 2.0\runes of sarnac 2.0\battle.cpp 91

Error 8 error C2143: syntax error : missing ';' before '}' c:\users\x d y n a s 7 y\desktop\afternoon\runes of sarnac 2.0\runes of sarnac 2.0\battle.cpp 151

Error 10 error C2143: syntax error : missing ';' before '{' c:\users\x d y n a s 7 y\desktop\afternoon\runes of sarnac 2.0\runes of sarnac 2.0\battle.cpp 154

Error 2 error C2064: term does not evaluate to a function taking 1 arguments c:\users\x d y n a s 7 y\desktop\afternoon\runes of sarnac 2.0\runes of sarnac 2.0\battle.cpp 90

Error 6 error C2059: syntax error : 'return' c:\users\x d y n a s 7 y\desktop\afternoon\runes of sarnac 2.0\runes of sarnac 2.0\battle.cpp 150

Error 7 error C2059: syntax error : '}' c:\users\x d y n a s 7 y\desktop\afternoon\runes of sarnac 2.0\runes of sarnac 2.0\battle.cpp 151

Error 9 error C2059: syntax error : '}' c:\users\x d y n a s 7 y\desktop\afternoon\runes of sarnac 2.0\runes of sarnac 2.0\battle.cpp 151

Error 12 error C2043: illegal break c:\users\x d y n a s 7 y\desktop\afternoon\runes of sarnac 2.0\runes of sarnac 2.0\battle.cpp 189
Double check your braces. You probably have mismatching braces somewhere.

It would be a lot easier to spot if you indented properly.

If you don't find it by the time I get home from work I'll give it another look.
thanks man...

i've formatted selection like 5 times... and its still messing up...
Line 79:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
					if(target > 0 && target <= count)
					{
						// check if target is alive
						if(list[target].GetHealth() > 0)
						{
							//attack the target
							AttackMonster(player,&list(choice-1))
							break;
						}
						else
						{
							cout << "Invalid monster.\n\n";
						}
//  Missing } here, it looks like
					else if(target == 0)
that seemed to fix the problem
thanks for all your help i appreciate it
Topic archived. No new replies allowed.