Hello!

I am using "random_seed" with defined seeds, to ensure a very particular random sequence.
But as it turns out, there are instructions other than "random" that affect the sequence. The following piece of code illustrates that. You'll need a model with a bone, here, the model is called "NPCGen_09.mdl", and the bone "head".

Code:
function main() {
	char i;
	ENTITY* test;
	
	level_load(NULL);
	wait(1);
	wait(1);
	wait(1);
	test = ent_create("NPCGen_09.mdl",nullvector,NULL);
	
	diag("n --- n");	
	random_seed(1);
	for(i=0;i<10;i++) diag_var("%6.3f ",random(1000));

	diag("n --- n");	
	
	random_seed(1);
	wait(-0.5); //<- does not affect the sequence
	for(i=0;i<10;i++) diag_var("%6.3f ",random(1000));

	diag("n --- n");	
	
	random_seed(1);
	//ent_bonerotate(test,"head",vector(0,0,1)); // <- affects the sequence -> shifts by one
	ent_bonemove(test,"head",vector(0,0,1)); // <- affects the sequence -> shifts by one
	//VECTOR t; t.x=0;t.y=0;t.z=1;ent_bonerotate(test,"head",t); //this also affects the sequence (so it's not "vector")
	for(i=0;i<10;i++) diag_var("%6.3f ",random(1000));
	
	sys_exit("");
	
}



After not much interesting stuff for initialization, "random_seed(1);" sets a sequence, of which the first 10 elements as found by random(1000) are output in the acklog:

Code:
123.260 903.473 52.917 600.677 70.313 519.378 507.935 306.091 807.098 556.549



Next up, to ensure that it's not just a general timing issue, I re-initialize the sequence, wait half a second, and output the first 10 elements. No change there.

But! Then we re-initialize the sequence, and call one of the ent_bone*-instructions. The 10 elements output are now shifted by one (we skip the "123.260"):

Code:
903.473 52.917 600.677 70.313 519.378 507.935 306.091 807.098 556.549 234.009





Why do these instruction affect the random sequence? Which other instructions do? Additionally, more information on the exact generation of the random sequence would be appreciated.

Thanks!

Last edited by Error014; 10/10/17 22:53.

Perhaps this post will get me points for originality at least.

Check out Dungeon Deities! It's amazing and will make you happy, successful and almost certainly more attractive! It might be true!