Help with *Actor,please.

Non-platform specific questions.

Help with *Actor,please.

Postby equinox » Sat Feb 21, 2009 11:38 am

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.
User avatar
equinox
 
Posts: 118
Joined: Tue Jan 29, 2008 3:38 pm
Score: 0 Give a positive score

Re: Help with *Actor,please.

Postby skydereign » Sat Feb 21, 2009 1:10 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Help with *Actor,please.

Postby equinox » Sat Feb 21, 2009 3:24 pm

Tnk for the esemple. Very util for me

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

and its elements, variables?
User avatar
equinox
 
Posts: 118
Joined: Tue Jan 29, 2008 3:38 pm
Score: 0 Give a positive score

Re: Help with *Actor,please.

Postby skydereign » Sat Feb 21, 2009 6:08 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Help with *Actor,please.

Postby equinox » Sat Feb 21, 2009 7:33 pm

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.
User avatar
equinox
 
Posts: 118
Joined: Tue Jan 29, 2008 3:38 pm
Score: 0 Give a positive score

Re: Help with *Actor,please.

Postby skydereign » Sun Feb 22, 2009 1:58 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Help with *Actor,please.

Postby equinox » Sun Feb 22, 2009 3:40 pm

You were very kind to help me.Tnk1000.

Another question:

Collision or / and "collide actor" is part of Actor?
User avatar
equinox
 
Posts: 118
Joined: Tue Jan 29, 2008 3:38 pm
Score: 0 Give a positive score

Re: Help with *Actor,please.

Postby skydereign » Sun Feb 22, 2009 7:29 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Help with *Actor,please.

Postby equinox » Sat Feb 28, 2009 7:08 pm

K, tnk for reply.
User avatar
equinox
 
Posts: 118
Joined: Tue Jan 29, 2008 3:38 pm
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron