Sorry for not having replied to your post Shadow12345. I understood a bit of that what you told and I have now read about vectors. I fixed a another problem with them but I don't understand how vectors could fix the big problem. I have created the weapons with a weapons class and there I have made a constructor which I use to create all the different weapons.
Code:
class weapons
{
public:
char* item_location;
int item_position;
double weight;
char* name;
int weapon_damage;
//Weapons constructor
weapons(char* wname, double wweight, int w_damage, int i_pos, char* i_location)
{
name = wname;
weight = wweight;
weapon_damage = w_damage;
item_position = i_pos;
item_location = i_location;
}
};
//name, weight, wdamage, position, location
weapons sword ("sword", 0.9, 4, 1,"");
weapons hammer ("hammer", 1.5, 6, 1,"");
And then I have made the arrays so I could go through every weapons item_location and name.
Code:
iloca[1] = sword.item_location;
iloca[2] = hammer.item_location;
iname[1] = sword.name;
iname[2] = hammer.name;
And here is the code which looks if the weapon is in the room and couts it if it is.
Code:
for (int y = 1; y < 3; y++)
{
if (iloca[y] == room.strCurrent_room)
cout << iname[y] << endl;
}
Is there a better way to do this?