Im working on a generic text-based RPG. I have a function (equipCheck) that checks if my items are equivalent to items in the item list. If so, the stats of my items become the stats that correspond to the item number. Then, after the for loops, it adds up all the stats for all 7 equipment types and puts them into my playerStats.
For some reason, after I do equipCheck, instead of the resulting stat being normal, or around 2, its like in the millions, and it changes each time.I'm very confused about why this is happening.
The +3 is because I set up the playerStats oddly. The first three stats, 0,1,2, which are Strength, Intelligence, and Dexterity, are not currently stats for items, so to get the 3rd, 4th,5th, and 6th stats, I need to do a +3.
I think you need to show more of the code. in particular the part where you declare the arrays playerStats and playerEquipsVal, and also where you assign initial values to those arrays.
I'm guessing either the arrays themselves contain invalid values, or considering the sample of code seen thus far, possible there are invalid subscripts or some incorrect usage elsewhere in the code. I dare say the complete code might be very long, and if so asking someone else to comb through it might be asking a lot.
What I might suggest instead is that you use a debugger to step through the relevant parts of the code line by line, watching the values of important variables as you do so.
I did a lot of debugging on my own (my program wont let me debug. I figured out it was because when I initialized the playerEquipsVal array it was playerEquipsVal[][4]; when it should have been playerEquipsVal[7][4]. It works great, thanks for taking the time to help me :D