Page 1 of 1

Help with *Actor,please.

PostPosted: Sat Feb 21, 2009 11:38 am
by equinox
Hi.

my code is:

Actor *a = CreateActor("c1", "icon", "(none)", "(none)", 100, 100, true);
strcpy(string, a->clonename);
a = getclone("c1.3");
a->xvelocity = 2;

..but...

a->HP <----energy for actor C1.3, NOT WORK!!

how can I set for each individual HP for C1.0, C1.1 ... C1.100?

Tnk1000, for help.

Re: Help with *Actor,please.

PostPosted: Sat Feb 21, 2009 1:10 pm
by skydereign
I'm not completely sure if this is what you wanted, but this can set all clones hp to a given value. You could adapt if further for any variable. I don't know anything about getclone2 but I think it can do a similar thing, maybe even better.
This would go in global code. It uses feral's cloneID function and a setor function to set all actor*s hp to a given value.
Code: Select all
#define MAX 100
char buffer[50];
char *cloneID(const char *cname, int cindex)
{
    sprintf(buffer,"%s.%d",cname,cindex);
    return(buffer);
}

void
unit_stat_hp_set (Actor * self, const char* actor, int hp_value)
{
    int i;
    for (i=0; i<MAX; i++)
    {
        self=getclone(cloneID(actor,i));
        self->HP = hp_value;
    }
}

When calling it, you would use,
Code: Select all
unit_stat_hp_set(a, name, hp); // hp being your desired HP

For the a->HP, is HP an actor variable, because it must be if you are to use it that way.

Re: Help with *Actor,please.

PostPosted: Sat Feb 21, 2009 3:24 pm
by equinox
Tnk for the esemple. Very util for me

Cna yuo explain,please, this to me incomprehensible structure Actors "struct" ,,,

and its elements, variables?

Re: Help with *Actor,please.

PostPosted: Sat Feb 21, 2009 6:08 pm
by skydereign
You want an explanation of structs? Structs are used by gameEditor as actor variables, or so it seems. A simple way of putting it is that they are containers for like variables. A simple struct would be that of a point. It holds two int variables, x and y.
Code: Select all
struct point
{
    int x;
    int y;
};

This creates a struct with those values inside. If you are familiar with the actor variables of gameEditor, they are the same thing as I previously stated. I'm not sure if this is what you wanted, or maybe it wasn't indepth enough... You seem to be knowledgeable in similar scripting, but if you need help just ask. The setor function can be used to set the values of the struct.

Re: Help with *Actor,please.

PostPosted: Sat Feb 21, 2009 7:33 pm
by equinox
yes, I understood.

But I do not know how the struct is the Actor. His elements or variables. cloneindex type or clonemane name or what and how to use.

No I can understand from. doc or tutorial by GE.

Re: Help with *Actor,please.

PostPosted: Sun Feb 22, 2009 1:58 am
by skydereign
I don't think there are any tutorials on structs... If there are I missed them completely. But for the most part they can be referenced through the same method used to set the HP. You can create struct variables for the actor. Each actor has a struct, lets say
Code: Select all
struct actorName
{
    double x;
    double y;
    char[] name;
    char[] clonename;
    int cloneindex;
    int height;
    int width;
    int animindex;
    int animpos;
    int nframes;
    int transp;
    int r;
    int g;
    int b;
    double directional_velocity;
    double angle;
    double xvelocity;
    double yvelocity;
    double xscreen;
    double yscreenl
    double xprevious;
    double yprevious;
    // And many many more.... The ones you create as actor variables appear
    // Not sure on all the types but I think they are right
}

These variables you can learn about, but most of them are self explanatory. You seem to already know how to use structs so I don't get your question, or maybe there was no question.

Re: Help with *Actor,please.

PostPosted: Sun Feb 22, 2009 3:40 pm
by equinox
You were very kind to help me.Tnk1000.

Another question:

Collision or / and "collide actor" is part of Actor?

Re: Help with *Actor,please.

PostPosted: Sun Feb 22, 2009 7:29 pm
by skydereign
I believe collide actor is, as any variable unique to the actor is part of the struct. Maybe 'collision' is too, but that is branching into more complex structs/objects so I don't know.

Re: Help with *Actor,please.

PostPosted: Sat Feb 28, 2009 7:08 pm
by equinox
K, tnk for reply.