Find Actor

Game Editor comments and discussion.

Find Actor

Postby DilloDude » Sun Apr 02, 2006 6:37 am

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.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby DilloDude » Mon Apr 03, 2006 5:56 am

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.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby Fuzzy » Mon Apr 03, 2006 10:05 am

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..
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: Find Actor

Postby DilloDude » Mon Apr 03, 2006 11:36 am

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.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby DilloDude » Tue Apr 04, 2006 3:41 am

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;
        }
    }
}
Last edited by DilloDude on Tue Apr 04, 2006 4:03 am, edited 2 times in total.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby DilloDude » Tue Apr 04, 2006 4:00 am

And I also should add a CollisionState enable in there, so they can be moved again.

And some rgb values = 255.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby DilloDude » Tue Apr 04, 2006 10:07 am

Ok, it really doesn't like that.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby DilloDude » Tue Apr 04, 2006 11:26 am

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?
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby DilloDude » Wed Apr 05, 2006 12:35 am

This time it displayed an error message:
Error: Access violation at 0x00527D7E (tried to write to 0x00000001), progam terminated.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby DilloDude » Fri Apr 07, 2006 11:20 pm

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!
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby DilloDude » Wed Apr 12, 2006 9:39 am

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...
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest