I'm not sure if this is the right place to post this, but here goes.
I have 5 armies, (both side1/side2) and 5 fronts as done in arrays, and a for-loop to handle them all. However, testing it makes it come out with very odd results... I seem to get the values only for the last 3 armies/fronts that I want to update, but not for the first two. Some of them are not updating correctly too. There is a value z used in the for loop for going through all the armies and fronts.
Example:
- Code: Select all
/check who is attacking
//used to check if the damage is taken to attacker's zeal
//or defend HP
void checkattacking() {
for ( z = 0; z <= 3; z++ ) {
if (turned == 1 & side1[z].isattacking == 1) {
turned = 0;
side1[z].isattacking = 0;
side2[z].isattacking = 1;
side1[z].zeal = 0;
side2[z].defhp = 0;
side2[z].zeal = 30;
side1[z].defhp = 30;
PlaySound2("data/scchh.wav", 1.000000, 1, 0.000000);
}
else if (turned == 1 & side2[z].isattacking == 1) {
turned = 0;
side1[z].isattacking = 1;
side2[z].isattacking = 0;
side1[z].zeal = 30;
side2[z].zeal = 0;
side2[z].defhp = 30;
side1[z].defhp = 0;
PlaySound2("data/scchh.wav", 1.000000, 1, 0.000000);
}
//check damage against defhp or zeal
//depending on attacker
for ( z = 0; z <= 3; z++ ) {
if (side1[z].isattacking == 1 & side2[z].isattacking == 0) {
if (fronts[z].differ < 0) {
side1[z].zeal = side1[z].zeal + differ;
PlaySound2("data/tuneuiw.wav", 1.000000, 1, 0.000000);
}
if (fronts[z].differ > 0) {
side2[z].defhp = side2[z].defhp - differ;
PlaySound2("data/scchh.wav", 1.000000, 1, 0.000000);
}
}
if (side2[z].isattacking == 1 & side1[0].isattacking == 0) {
if (fronts[z].differ > 0) {
side1[z].defhp = side1[z].defhp - differ;
PlaySound2("data/tuneuiw.wav", 1.000000, 1, 0.000000);
}
if (fronts[z].differ < 0) {
side2[z].zeal = side2[z].zeal + differ;
PlaySound2("data/scchh.wav", 1.000000, 1, 0.000000);
}
}
}
}
};
What could be the problem, or is there a better way to update a group of 5 armies/5 fronts (the battlegrounds where the armies fight) or 5 anything that are made with structs?
Also, minuscule question: Is there a way to make GE's script editor format stuff better? Formatting stuff in Notepad++ and importing them back in results in a jumbled mess.