Page 1 of 1

Rand moving to clones!

PostPosted: Sat May 02, 2009 11:28 am
by Camper1995
Hi ppl, I wanna know, how can I make this:
I have one player called P and 3 clone actor called E. So, when I click on
player, the player will move RANDOR to clone 1 or clone 2 or clone 3...
Is this possible?

Thanks, Camper :D

Re: Rand moving to clones!

PostPosted: Sat May 02, 2009 2:28 pm
by jimmynewguy
ummm im sure there is a better way to do this, but im too tired to think of one :lol:
Code: Select all
int random;
random = rand(number of clones);
switch(random)
{
case 0:MoveTo("Event Actor", 0.000000, 0.000000, 3.000000, "e.0", "");
break;
case 1:MoveTo("Event Actor", 0.000000, 0.000000, 3.000000, "e.1", "");
break;
//ect.
}


really long way though, maybe someone will think of the way i can't remember lol :lol:

Hold on i might have it gimme a sec

Re: Rand moving to clones!

PostPosted: Sat May 02, 2009 9:37 pm
by Camper1995
Man, I dont understand this :D :D :D

I have maked this, this way: I make variable caller "var"
So, on, player, when he create, var=ceil(rand(3)); //rand "var" for 3 clones...

Then, when you click on player, If(var==1)
mover to...
if(var==2)
move to...
ETC.
:)

Re: Rand moving to clones!

PostPosted: Sat May 02, 2009 10:55 pm
by jimmynewguy
my code is basically that same thing, let me break it down for you

Code: Select all
int random;//create the actor variable named random;
random = rand(3);// you know this since it was in your code :)
switch(random)//switch the variable so you don't have to do if(var == 1)ect; case is like if(var ==)
{
case 0:MoveTo("Event Actor", 0.000000, 0.000000, 3.000000, "e.0", "");//if case \\ 0 moveto actor 0
break;
case 1:MoveTo("Event Actor", 0.000000, 0.000000, 3.000000, "e.1", "");
break;
case 2:MoveTo("Event Actor", 0.000000, 0.000000, 3.000000, "e.2", "");
break;
}

Re: Rand moving to clones!

PostPosted: Sat May 02, 2009 11:28 pm
by skydereign
This is one way to do it. If you want me to explain I can, basically it uses getCloneIdx to give you the clones x and y.
Gobal Code
Code: Select all
Actor * getCloneIdx (const char *cname, int cindex)    //g_GetCloneByIndex, its original name
{
    char buffer[50];

    sprintf(buffer,"%s.%i",cname,cindex);

    return(getclone(buffer));
}

Actor* target;
int RANDOM;


Event that decides which clone to go towards
Code: Select all
RANDOM=rand(3);
target = getCloneIdx("E", RANDOM);
// Probably need a triggered variable


P->DrawActor->Script Editor
Code: Select all
// Probably need a conditional
MoveTo("Event Actor", target->x, target->y, 100, "Game Center", "");

Re: Rand moving to clones!

PostPosted: Sun May 03, 2009 7:59 am
by Camper1995
Oh, :D ...its little bit complicated for me, but, I try to do this with this code.

And just one question. I have an actor called "factory" and another actor called "smoke"
So, how to do, when the factory create, create actore smoke, but in top of factory.
So, this is easy, but how to do this, when I have clones, you know, that smoke will be moved only to the one factory, but I want,
everytime when you buy factory and when you build it, the smoke will be create to the smokestack of that factory...
Do you understand? :D :D

Thanks for helping me :D

Re: Rand moving to clones!

PostPosted: Sun May 03, 2009 8:13 am
by skydereign
The method I had before, if you can understand it, will help a lot with clone work. I can explain more if you want. It uses Actor*s, which allow you to access a specific actor. The function getIdxClone gives back a specific clone's Actor*, pending what idx you give it. That means you can use that clone directly, it is similar to the getClones.
Okay, so you want the most recent factory to have smoke created from the top? If the factories are just clones of themselves, and you really just want the most recent to make smoke, then in the draw script that creates the smoke, just do this
Code: Select all
if(cloneindex==(ActorCount("factory")-1))
{
    //Create Actor code here
}

Re: Rand moving to clones!

PostPosted: Sun May 03, 2009 2:29 pm
by jimmynewguy
just curious, what kind of game will this be :)

Re: Rand moving to clones!

PostPosted: Sun May 03, 2009 5:40 pm
by Camper1995
strategy, if you want, I can post demo :)
Its good game. :D

Re: Rand moving to clones!

PostPosted: Sun May 03, 2009 6:17 pm
by jimmynewguy
lol that's what i've been working on :lol: , can i see yours? I might post a demo for mine soon :)