Need help with text_based_rpg

Hi I'm fairly new to C++ and I am trying to write a text based RPG. I am having a few difficulties trying to add weapons to the game. I want to be able to have each class start out with a different weapon and be able to store a damage variable and name variable to each weapon. Is an array a good choice?
Also, I noticed that when I choose a class in the program, the stats aren't being shown when they should be.
thanks in advance

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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
#include <iostream> 
#include <string>
#include <ctime>
#include <cstdlib>
#include <time.h>
#include <cstdio>
#include <stdlib.h>
#include <conio.h>
#include <fstream>
#include <windows.h>
using namespace std;
// STRUCT
struct enemy
{
	int enStr;
	int enCon;
	int enDex;
	int enIntel;
	int enWis;
	int enExp;
	int enGold;
	int enLevel;
	char enDescrip[500];
	char enName[50];
	};
struct weapons
{ 
	char wepName[20];
	char wepDescript[100];
};
struct clas
{ 
	int cStr;
	int cCon;
	int cDex;
	int cInt;
	int cWis;
	char cName[32];
	};
void initializeClas();
void initializeEnemy();
void initializeWeapons();
weapons weaponsArray[10];
clas clasArray[3];
enemy enemyArray[20];

void initializeWeapons()
{
	strcpy(weaponsArray[1].wepName, "Iron Dagger");
	strcpy(weaponsArray[1].wepDescript, "An old, slightly rusty dagger.");
	weaponsArray[1].weaponDamage = 3;

	strcpy(weaponsArray[2].wepName, "Iron Short Sword");
	strcpy(weaponsArray[2].wepDescript, "");
	weaponsArray[2].weaponDamage = 4;

	strcpy(weaponsArray[3].wepName, "Iron Long Sword");
	strcpy(weaponsArray[3].wepDescript, "");
	weaponsArray[3].weaponDamage = 6;

	strcpy(weaponsArray[4].wepName, "Iron Two-Handed Sword");
	strcpy(weaponsArray[4].wepDescript, "");
	weaponsArray[4].weaponDamage = 8;

	strcpy(weaponsArray[5].wepName, "Steel Dagger");
	strcpy(weaponsArray[5].wepDescript, "");
	weaponsArray[5].weaponDamage = 5;

	strcpy(weaponsArray[6].wepName, "Steel Short Sword");
	strcpy(weaponsArray[6].wepDescript, "");
	weaponsArray[6].weaponDamage = 7;

	strcpy(weaponsArray[7].wepName, "Steel Long Sword");
	strcpy(weaponsArray[7].wepDescript, "");
	weaponsArray[7].weaponDamage = 9;

	strcpy(weaponsArray[8].wepName, "Steel Two-Handed Sword");
	strcpy(weaponsArray[8].wepDescript, "");
	weaponsArray[8].weaponDamage = 11;

	strcpy(weaponsArray[9].wepName, "Wooden Stave");
	strcpy(weaponsArray[9].wepDescript, "");
	weaponsArray[9].weaponDamage = 5;
}

void initializeenemy()
{
     strcpy(enemyArray[1].enName, "Skeleton");
     strcpy(enemyArray[1].enDescrip, "A rotting old skeleton");
     enemyArray[1].enLevel = 1;
     enemyArray[1].enStr = 6;
     enemyArray[1].enCon = 5;
     enemyArray[1].enDex = 3; 
     enemyArray[1].enIntel  = 2;
     enemyArray[1].enWis = 3;
     enemyArray[1].enExp = 2;
     enemyArray[1].enGold = 5;
     
     strcpy(enemyArray[2].enName, "Zombie");
     strcpy(enemyArray[2].enDescrip, "");
     enemyArray[2].enLevel = 2;
     enemyArray[2].enStr = 8;
     enemyArray[2].enCon = 7;
     enemyArray[2].enDex = 2;
     enemyArray[2].enIntel  = 3;
     enemyArray[2].enWis = 2;
     enemyArray[2].enExp = 4;
     enemyArray[2].enGold = 8;
     
     strcpy(enemyArray[3].enName, "Goblin");
     strcpy(enemyArray[3].enDescrip, "");
     enemyArray[3].enLevel = 3;
     enemyArray[3].enStr = 9;
     enemyArray[3].enCon = 5;
     enemyArray[3].enDex = 12;
     enemyArray[3].enIntel  = 3;
	 enemyArray[3].enWis = 4;
     enemyArray[3].enExp = 6;
     enemyArray[3].enGold = 14;
     
     strcpy(enemyArray[4].enName, "Orc");
     strcpy(enemyArray[4].enDescrip, "");
     enemyArray[4].enLevel = 4;
     enemyArray[4].enStr = 12;
     enemyArray[4].enCon = 10;
     enemyArray[4].enDex = 6;
     enemyArray[4].enIntel  = 5;
	 enemyArray[4].enWis = 2;
     enemyArray[4].enExp = 8;
     enemyArray[4].enGold = 18;
}
void initializeClas()
{
     strcpy(clasArray[1].cName, "Warrior");
     clasArray[1].cStr = 10;
     clasArray[1].cCon = 8;
     clasArray[1].cDex = 8;
     clasArray[1].cInt = 4;
	 clasArray[1].cWis = 3;
     
     strcpy(clasArray[2].cName, "Rogue");
     clasArray[2].cStr = 6;
     clasArray[2].cCon =7;
     clasArray[2].cDex = 12;
     clasArray[2].cInt = 7;
	 clasArray[2].cWis = 5;
     
     strcpy(clasArray[3].cName, "Wizard");
     clasArray[3].cStr = 4;
     clasArray[3].cCon = 6;
     clasArray[3].cDex = 8;
     clasArray[3].cInt = 16;
	 clasArray[3].cWis = 10;
}
	int enName, enLevel;
	int playerStrength; 
	int playerDexterity;
	int playerConstitution;
	int playerWisdom;
	int playerIntelligence;
	int playerHealth = 100;
	int playerMaxHealth = 100 + ((playerConstitution - 10) / 2) * 10;
	int playerMana= 100;
	int playerMaxMana = 100 + ((playerIntelligence - 10) / 2);
	int math400 = playerDexterity / 2;
	int math401 = playerConstitution / 2;
	int math402 = playerWisdom /2;
	int rflx = math400;
	int fort = math401;
	int will = 402;
	int playerAC = (playerDexterity - 10) / 2 + 10;
	int playerAttackBonus = (playerStrength - 10) / 2;
	int playerDmgBonus = 0;
	int playerAttack;
	int playerDefense;
	int playerLevel;
	int playerExperience;
	int expForNextLevel;
	int weaponDamage;
	int wweapons;
	int cclas;
	int eenemy;
	std::string equippedWeapon;
	std::string startingWeapon;
	char playerName[50];
int main()
{
CHARACTERCREATION:system("cls");
initializeClas();
initializeWeapons();
	cout << "\n\n                        CHARACTER CREATION";
	cout << "\n\n   step 1/2";
	cout << "\n\n   Enter your name: ";
	cin >> playerName;
step2:
	system("CLS");
	cout << "\n\n                        CHARACTER CREATION";
	cout << "\n\n   step 2/2";
	cout << "\n\n   Select a class:    1. WARRIOR";             
	cout <<"\n                      2. ROGUE";
	cout <<"\n                      3. WIZARD";
	cout <<"\n			4. Return to Main Screen";
	cout <<"\n\n                      Input: "; 
	cin >> input;
				 
	playerLevel = 1;

	playerStrength = clasArray[cclas].cStr;
	playerDexterity = clasArray[cclas].cDex;
	playerConstitution = clasArray[cclas].cCon;
	playerIntelligence = clasArray[cclas].cInt;
	playerWisdom = clasArray[cclas].cWis;

	playerHealth = playerConstitution * playerLevel / 2 + playerStrength + playerDexterity / 4;
	playerMaxHealth = playerConstitution * playerLevel / 2 + playerStrength + playerDexterity / 4;

	playerMana = playerIntelligence * playerLevel / 2 + playerWisdom + playerDexterity / 4;
	playerMaxMana = playerIntelligence * playerLevel / 2 + playerWisdom + playerDexterity / 4;
	playerExperience = 0;
	expForNextLevel = 10;
	weaponDamage = weaponsArray[wweapons].weaponDamage;
	startingWeapon = weaponsArray[wweapons].wepName;

	playerAttack = (playerStrength * 2 + playerDexterity + weaponDamage) / 3;
	playerDefense = (playerDexterity * 2 + playerStrength + playerAC) / 3;
inventory:
	system("cls");
	cout << "Backpack" << endl;
	cout << "\n\n1. " << startingWeapon << endl;
	cout << " Health Potions: " << healthPotion << endl;
	cout << " Mana Potions: " << manaPotion << endl;
	cout << "\n\n		Input the number of the item you wish to equip.\n\n Or press 9 to return to the game." << endl;
	cout << "\n				Input: " << endl;
	cin >> input;

	switch (input)
	{
	case 1: weaponDamage = weaponsArray[wweapons].weaponDamage;
		cout << "\n\nYou have equipped the " << startingWeapon << endl;
		getch();
	case 9: goto Main_Menu;
	default: goto inventory;
	}
	getch();
character_screen:
	system("cls");
	cout << "\n\n\n		Name: " << playerName << endl;
	cout << "\n			Level: " << playerLevel << endl;
	cout << "			Class: " << clasArray[cclas].cName;

	cout << "\n			Experience: " << playerExperience << "/ " << expForNextLevel << endl;
	cout << "\n			Health Points: " << playerHealth << "/ " << playerMaxHealth << endl;
	cout << "			Mana: " << playerMana << "/ " << playerMaxMana << endl;
	cout << "\n			Attributes: " << endl;
	cout << "\n			Strength: " << playerStrength << endl;
	cout << "			Dexterity: " << playerDexterity << endl;
	cout << "			Constitution: " << playerConstitution << endl;
	cout << "			Intelligence: " << playerIntelligence << endl;
	cout << "			Wisdom: " << playerWisdom << endl;

	cout << "\n		Weapon Damage: " << weaponDamage << endl << endl;
Last edited on
Topic archived. No new replies allowed.