Fair enough, my mistake, sorry

Code:
BMAP* texture2 = "empty.bmp";

//first, i start with this function (ignore the name) its job is to 
//color a square sized bitmap randomly, im 99% shure my problem doesn't come from this function. 
//Notice it doesn't return anything

void bmap_square_drawColor(BMAP* bmap, var alpha)
{
	var format = bmap_lock(bmap, 0);
	var pixel;
	var width = bmap_width(bmap);
	var height = bmap_height(bmap);
	var i, j;
	
	for(j=0 ; j < width ; j++)
	{
		pixel = pixel_for_vec(vector(random(255),random(255),random(255)), alpha, format);
		for(i=0 ; i< width ; i++)
		{
			pixel = pixel_for_vec(vector(random(255),random(255),random(255)), alpha, format);
			pixel_to_bmap(bmap, i, j, pixel);
		}
	}
	bmap_unlock(bmap);
	
}

//then there's the function to deform the initial cubes 
//into smaller randomly deformed spheres, actually

function cube_deform(ENTITY* model, var ray) 
{
  int i = ent_status(model,0); 
  for (; i>0; i--) 
{    														 
  	CONTACT* c = ent_getvertex(model,NULL,i);   
  	vec_normalize(c.x, ray);
  	c.y += random(50)-50;
  	c.z += random(50)-50;
  	c.v = NULL;   // set c.v to NULL to change c.x,y,z 
  	ent_setvertex(model,c,i);					 
  	}
  	
	ent_fixnormals(model, 0); // fix the not updating shading (shadow) on the model

}

//these next 2 functions serve to generate the entities
//call on them cube_deform() and bmap_square_drawColor()

function asteroid_modify(ENTITY* ast_i)
{
	set(ast_i,SHADOW);
	cube_deform(ast_i, (100 + random(50)));
	ast_i.scale_x = 0.05;
	ast_i.scale_y= 0.05;
	ast_i.scale_z = 0.05;
	ent_cloneskin(ast_i);
	bmap_square_drawColor(texture2, 255);
	ent_setskin(ast_i,texture2,1);
}

function generate_asteroids()
{
	ENTITY* asteroid[200]; //initialize asteroid array
	int i;
	for (i=0 ; i<200 ; i++)
		{
			asteroid[i] = ent_create("cube_small.mdl", vector(500,(0 + 20*i),0), NULL);
			ent_clone(asteroid[i]);
			wait(40);
			bmap_square_drawColor(texture2, 255);
			asteroid_modify(asteroid[i]);
		}
}



So, it should be: for each new asteroid in the array, when reading asteroid_modify(), first they're deformed, then scaled down, then their skin is cloned (not needed, but i used it anyway), then i call on their skin (texture2) bmap_square_drawColor() to randomly color each of them, then i set this modified skin as each of the entities's skin (texture2 after bmap_square_drawColor() being called on it)

since i call
Code:
ent_cloneskin(ast_i);
bmap_square_drawColor(texture2, 255);
ent_setskin(ast_i,texture2,1);


for each asteroid in the array, each one of them should be stuck with a diferently coloured texture2, shouldn't it?

EDIT: i know the code is a mess, and it isn't even complete, its way to big and messy, good luck finding the mistake (i know there's one somewhere)
And thank you

Last edited by joao13pt; 06/08/13 17:15.