for(r=1;r<7;r++)
{
if(attacking_pwitch == r) //which witch?
{
for(s=1;s<13;s++)
{
if(attacking_pwitcht == s)//witchtype?
{
if(w_typempcurr[r] >= 2) //have enough magic
{
w_typempcurr[r] -= 2; //subtract magic
}
else
{
beep();
return;
}
}
}
}
}

okay. what I have is 6 witches on a board. these witches can be of 1 of 12 types(witchtype).

The 1st loop 'r' is finding the actual witch witch1 - witch6.
the 2nd loop 's' is finding the type of witch the first loop has found. when the witch and the witch type is found it checks to see if there is enough magic to perform the spell and subtracts that amount from the w_typempcurr, or the current amount of magic for this witch...

The problem I am having is that the for loop keeps selecting the first witch even though in a previous function, I specify which witch to select via another for loop. attacking_pwitch and attacking_pwitcht are global vars. "s" and "r" are local vars.

no matter which witch I click, the magic is always drawn from the 1st witch's bank. I have had this problem with several other for loops and thought it to be a timing issue, but even with placing wait(-1); before the function doesn't fix the issue.

I have considered writing it out the long way, but I wanted to know what I am doing wrong and see if I can fix it first.

it seems like it would be an easy fix, but I can't seem to figure it out.

note: I am using 1-7 and 1-13 for the for loops because the banks of magic and the witches are number 1-6 and 1-12.

thanks.


a8 commercial