I need to declare a variable, without simply stating what it is? Is there anyway to do that? Why I need to is I am making a text game, so when the player fights I don't have to guess what weapon they have. So how would I do this? Here's the fight script part.
Ideally you will have a lookup table of the available weapons
1 2 3 4 5 6 7
map<string, int> weapons;
weapons["sword"] = 2.0; // 2.0 dmg per hit
weapons["dagger"] = 1.0;
string playerWeapon = "sword";
int dmg = weapons[playerWeapon];
Now, that is kinda a crude solution. It'd be better to use some object orientated development with polymorphism here. But since you're trying to keep it simple doing it the way I've shown is probably not a bad idea. Also, you could swap the strings for enum to improve performance and reduce the possibility of spelling mistakes, but at this level it's likely not important.
When they hit I want their damage to be a random number according to their weapon. I won't always know their weapon, but every time they attack it's the same damage with this code. Help?