Hello!
There is my little contribution for the community of GameStudio
It's a simple action that replicate one or two objects. The code is below:

Code:

/*
A_REPLICATOR - A replicator entity utility :-)
Any kind of use is allowed but no warranty, use at your own risk!

STRINGS

string1 = first object to load
string2 = second object to load (leave blank for none)

SKILLS

1 = area width
2 = area depth
3 = area height
4 = number of objects to replicate
5 = scale axis X
6 = scale axis Y
7 = scale axis Z
8 = pan
9 = tilt
10 = roll
11 = random for pan
12 = random for tilt
13 = random for roll

14 = random % for scale X
15 = random % for scale Y
16 = random % for scale Z

17 = offset position X
18 = offset position Y
19 = offset position Z


FLAGS

1 = passable
*/

function f_replicated(){

if(you.flag1) {
my.passable = on;
}

var percent_x;
var percent_y;
var percent_z;

percent_x = you.SKILL5/100 * you.SKILL14;
percent_y = you.SKILL6/100 * you.SKILL15;
percent_z = you.SKILL7/100 * you.SKILL16;

my.scale_x = you.SKILL5 + random(percent_x);
my.scale_y = you.SKILL6 + random(percent_y);
my.scale_z = you.SKILL7 + random(percent_z);

my.x += you.skill17 * my.scale_x;
my.y += you.skill18 * my.scale_y;
my.z += you.skill19 * my.scale_z;

my.pan = - you.SKILL8/2 + random(you.SKILL11);
my.tilt = - you.SKILL9/2 + random(you.SKILL12);
my.roll = - you.SKILL10/2 + random(you.SKILL13);
}

function f_replica_objects() {
var width;
var depth;
var height;
var objects;
var scelta;

width = my.SKILL1;
depth = my.SKILL2;
height = my.SKILL3;
objects = my.SKILL4;

var conta = 0;
randomize();
while(conta<objects) {
conta +=1;
temp.x = my.x - width/2 + random(width);
temp.y = my.y - depth/2 + random(depth);
temp.z = my.z - height/2 + random(height);
if (my.string2 != NULL) {
scelta = int(random(2));
if(scelta==1){
ent_create(my.string1,temp,f_replicated);
}
else {
ent_create(my.string2,temp,f_replicated);
}
}
else {
ent_create(my.string1,temp,f_replicated);
}
}
}

action a_replicator {
f_replica_objects();
}



And this is an example result



*INSTRUCTIONS (VERY SIMPLE) *

Place the action a_replicator to any entity in your level. Use string1 and (if you want) string2 to store the filename of the entity to replicate.
See the code for skills and flags reference.

Have a nice coding and feedbacks are welcome!

Please note that this don't want to be a professional coding and don't want to replace the particle system too. It's only my discovering the gamestudio. Thank You!

Last edited by ato; 05/30/07 12:11.