Page 1 of 1

Random appearance of actors

PostPosted: Tue Dec 13, 2005 1:38 am
by Diana Kennedy
Hi to all!

I have two main questions about the random appearance of actors. I am pretty sure that they have been ansewered yet, I even found related topics but I wasn't able to "get it". So I try it this way:

First, I would like to know if this is possible:

You have a main actor, lets call him "master" he is visible from the start on and 24 actors, A, B, A1 and so on, that are not visible,.
When the player clicks on the master, one of those 24 actors appear, at random, in a not predictable way. Means: Once I clic and actor A appears, then I click and actor G2 appears and so on.


--------------

Seccond:

In my Game with the Birds and the Guys, all actors appear with the help of a timer. This make them appear in a specific order, not all together. That's good. But much better would it be, if they also would appear in a random, not predictable rythm.

PostPosted: Tue Dec 13, 2005 9:46 am
by Novice
Try this
on mouse down-->
Code: Select all
int RandActor=round(rand(23));
if (RandActor==0) CreateActor(A1);
else if (RandActor==1) CreateActor(A2);
...

This is what i can tink of right now if anyone has a better way please do say.
In my Game with the Birds and the Guys, all actors appear with the help of a timer. This make them appear in a specific order, not all together. That's good. But much better would it be, if they also would appear in a random, not predictable rythm.

Use a random timer and set min and max times.

PostPosted: Wed Dec 14, 2005 1:47 am
by Diana Kennedy
Okya, thank you for the random timere. It worked.

As for the random apearance, I copypasted the code, but it sayed that there were errors in the line :( I probably should have ad or adjust somethinng..

PostPosted: Wed Dec 14, 2005 11:49 am
by Novice
My bad. :oops:
Code: Select all
int RandActor;
RandActor=round(rand(23)); //You have to first make it then define it.
if (RandActor==0) // Use the crate function my last one was just an example.
//It should go something like
CreateActor("ActorName",0,0,false);

I dont know it by heart so this is maybe incorect (im not at my GE computer)
just use the button for the create acotr function in script editor and it should do the rest.

PostPosted: Sun Dec 18, 2005 1:49 am
by Diana Kennedy
Thanks for your patiente,

:cry: It did not work. I am probably way to dumb and most before all would need more scripting knowledge for it.

Well, I have packed my test ged into a Zip-File for downbload. If anyone feels in the mood to try it out and ad the script, it would be cool. I probably can only learn when I see it realted in my game and then can find out how it goes on the living example. maybe this would also make a little tutorial for others. There are default graphics by now, but if this evolves into a tutorial I would ad real graphics. Ah and yes: For some reason I was unable to zip the folders separatley. So the graphics are not in the "data" folder but loose with the ged files. You'll have to rebuild the data folder.

http://johnfkennedy.chez-alice.fr/funpics/random.zip

PostPosted: Sun Dec 18, 2005 2:15 pm
by makslane
In you clickon actor, Mouse Down Button event, put this script:

Code: Select all
//Get random actor number
int RandActor=round(rand(6));

//Get random position from -200 to 200 relative to this actor
int xpos = rand(400) - 200;
int ypos = rand(400) - 200;

//Create the actor
if (RandActor==0) CreateActor("A1", "a1", "no parent", "no path", xpos, ypos, false);
else if (RandActor==1) CreateActor("A2", "A2", "no parent", "no path", xpos, ypos, false);
else if (RandActor==2) CreateActor("A3", "a3", "no parent", "no path", xpos, ypos, false);
else if (RandActor==3) CreateActor("A4", "A4", "no parent", "no path", xpos, ypos, false);
else if (RandActor==4) CreateActor("A5", "A5", "no parent", "no path", xpos, ypos, false);
else CreateActor("A6", "A6", "no parent", "no path", xpos, ypos, false);

PostPosted: Sun Dec 18, 2005 3:19 pm
by Diana Kennedy
Cool! Thank you very much. Now I can try to understand the concept and work on that script to expand the whole thing.

:D

PostPosted: Mon Jan 02, 2006 11:00 am
by Diana Kennedy
Hi Markslane,


I have a little problem with the script. I wanted to use it in my hunting game: Instead of normal actors, for text actors. So Ich changed the actors names in the script and deleted the animation names. (since they have no animation) Something like this:


Code: Select all
//Get random actor number
int RandActor=round(rand(6));

//Get random position from -200 to 200 relative to this actor
int xpos = rand(400) - 200;
int ypos = rand(400) - 200;

//Create the actor
if (RandActor==0) CreateActor("Originator1", "no parent", "no path", xpos, ypos, false);
else if (RandActor==1) CreateActor("Originator2", "no parent", "no path", xpos, ypos, false);
else if (RandActor==2) CreateActor("Originator3",  "no parent", "no path", xpos, ypos, false);
else if (RandActor==3) CreateActor("Originator4", "no parent", "no path", xpos, ypos, false);
else if (RandActor==4) CreateActor("Originator5",  "no parent", "no path", xpos, ypos, false);
else CreateActor("Originator6", "no parent", "no path", xpos, ypos, false);


These Originator 1, 2 and so on actors are text actors that create the set of animals. In fact what I wanted to do is in the entry panel of the game, the player clicks on enter. The enter actor is the "clickon" actor which creates randomly an "originator", so that each time you enter the game you will encounter a different world. (one of six) See what I mean? But the above modified script does not work. When I type it in, it gives me error messages.

I would greatly apreciate it, if you could look at it and see why.

PostPosted: Mon Jan 02, 2006 11:53 am
by makslane
Actor's without animations, like text actors, are created in this way:

CreateActor("Originator1", "icon", "no parent", "no path", xpos, ypos, false);

Tip: If you get syntax error messages in the Script Editor, try use the "variable/functions" list to select the function. For most functions, after select, will open a panel that you can use to put the function info and get the generated code.

PostPosted: Mon Jan 02, 2006 11:28 pm
by Diana Kennedy
Thank you very much! It worked - well, at least it loads the different Originators. Since only one originator is programmed to create a fauna for now, I really can tell it only when all are ready and the whole concept works. But I am pretty confident. I will try to get trough what you said in your tip!

8)

Say...I am afraid the finished game will have hundreds of MBs...The intro alone is 11MB by now. :shock: