Page 1 of 1

Find Actor

PostPosted: Sun Apr 02, 2006 6:37 am
by DilloDude
Does anyone know how i can search through all actors (or all of specified actors) and find one with a particular variable? For example, i want for a keydown to find which actor has tha actor variable Sel ==1, and find another actor variable from that actor.

PostPosted: Mon Apr 03, 2006 5:56 am
by DilloDude
Also, is there a way to cycle actors? I want to cycle actors, and for each one, I want to find out some information and change some information relative to actor variables. I could sendActivationEvent to each actor I want to check, but is there a simpler way where I only need one peice of code.

PostPosted: Mon Apr 03, 2006 10:05 am
by Fuzzy
If you know how many actors you will have at a given time, you can make an array that size and store their pointers as they are created(create actor event).

then loop thrugh the array to use them. Thats a bit advanced..

Re: Find Actor

PostPosted: Mon Apr 03, 2006 11:36 am
by DilloDude
Self wrote:Does anyone know how i can search through all actors (or all of specified actors) and find one with a particular variable? For example, i want for a keydown to find which actor has tha actor variable Sel ==1, and find another actor variable from that actor.

I am thinking of just having on the collision event which selects the actor, set a string variable to the selected actor's name. I think this should do the trick.

PostPosted: Tue Apr 04, 2006 3:41 am
by DilloDude
For my cycle actors, if I want to add 4 to the HP of each actor with the variable heal=1, would this function work?
Code: Select all
void CheckHeal(char *nam;)
{
    int i;
    char *ns;
    char *nc;
    for(i=0; i<(ActorCount(nam)); i++)
    {
        strcpy(nc, nam);
        sprintf(ns, ".%d", i);
        strcat(nc, ns);
        if(getclone(nc)->heal)
        {
            getclone(nc)->HP+=4;
        }
    }
}

PostPosted: Tue Apr 04, 2006 4:00 am
by DilloDude
And I also should add a CollisionState enable in there, so they can be moved again.

And some rgb values = 255.

PostPosted: Tue Apr 04, 2006 10:07 am
by DilloDude
Ok, it really doesn't like that.

PostPosted: Tue Apr 04, 2006 11:26 am
by DilloDude
It just freezes (and if done on create actor)dosn't draw anything, and when I press escape, it exits Game Editor.
I also have another instsnce where this happens, when I activate the function
Code: Select all
void Shoot(int xpo, int ypo)
{
    char *col;
    int ST = getclone(SNam)->ShotType;
    strcpy(col, getactor(xpo, ypo)->clonename);
    if(getclone(col)->Type==Unit && getclone(col)->Side!=Side)
    {
        strcpy(col, getactor(xpo, ypo)->clonename);
        switch(getclone(col)->HitType)
        {
            case G:
            if(getShot(1, ST))
            {
                CreateActor("GBang", "Ground_Bang", "no parent", "no path", xpo, ypo, true);
                Move=0;
                CollisionState(SNam, DISABLE);
                ChangeParent(SNam, "no parent");
                getclone(SNam)->Sel=0;
                getclone(SNam)->r=150;
                getclone(SNam)->g=150;
                getclone(SNam)->b=150;
                EventDisable("Event Actor", EVENTKEYDOWN);
            }
            break;
 
            case A:
            if(getShot(2, ST))
            {
                CreateActor("ABang", "Air_Bang", "no parent", "no path", xpo, ypo, true);
                Move=0;
                CollisionState(SNam, DISABLE);
                ChangeParent(SNam, "no parent");
                getclone(SNam)->Sel=0;
                getclone(SNam)->r=150;
                getclone(SNam)->g=150;
                getclone(SNam)->b=150;
                EventDisable("Event Actor", EVENTKEYDOWN);
            }
            break;
 
            case S:
            if(getShot(3, ST))
            {
                CreateActor("SBang", "Sea_Bang", "no parent", "no path", xpo, ypo, false);
                Move=0;
                CollisionState(SNam, DISABLE);
                ChangeParent(SNam, "no parent");
                getclone(SNam)->Sel=0;
                getclone(SNam)->r=150;
                getclone(SNam)->g=150;
                getclone(SNam)->b=150;
            }
            break;
 
            case U:
            if(getShot(4, ST))
            {
                CreateActor("UBang", "Sub_Bang", "no parent", "no path", xpo, ypo, false);
                Move=0;
                CollisionState(SNam, DISABLE);
                ChangeParent(SNam, "no parent");
                getclone(SNam)->Sel=0;
                getclone(SNam)->r=150;
                getclone(SNam)->g=150;
                getclone(SNam)->b=150;
                EventDisable("Event Actor", EVENTKEYDOWN);
            }
        }
    }
}

in which SNam is an actor's clonename; getShot(1, ST) should return 1; getShot(2, ST) should return 0; getShot(3, ST) should return 1 and getShot(4, ST) should return 0 and G, A, S, U and Unit are constants.

Does anyone know why this happens and how it can be fixed?

PostPosted: Wed Apr 05, 2006 12:35 am
by DilloDude
This time it displayed an error message:
Error: Access violation at 0x00527D7E (tried to write to 0x00000001), progam terminated.

PostPosted: Fri Apr 07, 2006 11:20 pm
by DilloDude
I'm thinking for my Shoot function, I only need to check the getShot values of SNam and create an actor for those values, rather than checking the HitType of the actor in the specified position.
But I still need a way to cycle through my actors. I want to enter an actor name, and it will go through each clone of that actor, and fiind some variables and change some variables. I haven't found a working solution yet, and it gets annoying, because I keep thinking of more things to do with it.
:D for those who give any help.
:evil: for those who don't.
Just kidding!

PostPosted: Wed Apr 12, 2006 9:39 am
by DilloDude
GOOD NEWS!
I have solved my cycle actor problem! Now I can work on the next stage in my game. It seems like it is nearly ready to do a demo version, but there are still a few problems to fix. Some of them may not be in the demo though, so one of the main things is creating new actors and copying script from others and adding the necesary modifications.One problem though...