Hi everyone. I've been doing some work for a project that involves attributes for an RPG game.
There's a part that uses if statements for attribute checking.
if (attributes[charisma]>3 && attributes[toughness]>6
&& attributes[agility]<7 && attributes[strength]<7 &&
attributes[intelligence]<7)
{
strcat(part1, tghJobs[randomSpecialJob]);
// If toughness is high enough, use a tough job.
}
The problem here is that if it passes the checks in more than one attribute, then it doesn't do it for any of them.
The only way I can think of how to fix this is to make a condition for each possible situation, e.g
The problem here is that if it passes the checks in more than one attribute, then it doesn't do it for any of them.
This is a bit confusing. The condition you have means that ALL the conditions must evaluate to true, otherwise the code in braces won't execute. It sounds as though that is what is happening.
Try using the debugger to keep an eye on the values of variables. Hopefully you can also evaluate individual expressions. Should be easy if you have an IDE.
Edit: Your else if has different conditions to the original if statement, - you will have to do this if you want this behaviour.