So I have been working on this as part of a school assignment that's worth almost the entire course (min. 14 credits to pass, there are a total of 24 I could get though). And I came across this problem with my battle system; every time I attack I deal about 7 million damage. This is when I draw the damage value from an item in the main hand weapon, add it to the off hand weapon and add a +1 for base damage.
There aren't too many comments, there wasn't much space left and it is pretty strait forward and logical but it looks like this:
I have itemcout uinitialised as one so that it equips it in the first slot, also I have put different items in the inventory and all of them were displayed. (Picking up items is in a different function). Also I apoligise fot the lack of comments in the code.
As for not being C++, I'm not all that good at it and thats what I know of programming in general.
I removed the part where it calls main in the playerwin() and enemywin() functions, and now it doesn't crash.
For the damage problem; I'm not sure where that comes from; in all places where I assign or declare the damage it is always to playeritems[3]. That was why I posted it here.
There's a few things I see that is making your life hard right now.
1. You're using global variables instead of passing arguments to your function calls. This is a very dangerous practice in my opinion.
1 2 3 4
void somefunction (Player & cPlayer)
{
}
This is much, much safer than using global variables. Once you learn to pass by reference, you'll fall in love with it.
Don't want to allow the function to change the original values?
1 2 3 4
void somefunction (const Player & cPlayer)
{
}
2. I guarantee that you're doing 7million damage because you didn't initialize a variable properly. How do I know? Because it happened to me when I was working on my text based RPG. A couple values were in the -7394184 or whatever range, some quick debugging revealed to me that I didn't properly initialize some values (or rather, at all).
3. I don't know what compiler you use, but you should add a breakpoint when you initialize your player's damage, so you can check each variable individually by using the Debug -> Windows -> Watch window. You can type in a variable and it'll display its current value. You can also change the values while your program is running.