(Sorry this thread got so old, I was busy doing other things...)

So, I've been thinking (just recently) about how to implement this "mag_scan()" function, and I'm kind of at a loss. I don't know what my "you" pointer would be (the entity that the code would work with, along with the one that the function is being executed from, "me"). Do I just create a dummy pointer and set it to the address of (&) the last MAGNET* created? That would kinda screw things up, because then I would have to make the "tmp" MAGNET* that my mag_create() function allocates into memory a global struct. Would this affect the way mag_create() works?

Or perhaps I could create "mee" and "yoo" pointers of type void

EDIT: Ok, I've come up with a solution akin to Kenchu's Idea of using arrays. I figure that since in my mag_create() function, I'm allocating a memory block to each new MAGNET* entity that is created, I would compare the distance values of the entities (tmp->entity->x/y/z via vec_dist()), and compare the "pole" members of the MAGNET* struct. The thing is, how do I access these parts of a struct array, if it's an array at all? (I figure it is, because the malloc() macro is just like new in C++, which can create dynamic arrays.)

Some pseudo-code to show what I'm attempting to do here:

Code:

void mag_scan(MAGNET* srcent,float dist)
{
int pole;
while(srcent)
{
for(int i= 0; i < tmp[i]; i++)
{
if(vec_dist(vector(insert pointer to tmp's entity coords here),vector(tmp->entity->x/y/z) <= 40)
{
switch(pole)
{
case POSITIVE:
//behavior (trig,other math nonsense)
case NEGATIVE:
//ditto
}
}
}
wait(1);
}
}



I've made the "tmp" pointer global, so this pseudo-code would work, if it were real, and if I knew how to access the array index of my MAGNET*s.

Last edited by MrCode; 02/26/08 23:57.

Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}