Random Character generator

I got bored and yer…the title explains it all… I didn’t feel as though this was worthy to post in the code gallery lol but yuh… just thought I might share my thoughts…
Its a character generator that spits out a random person everytime(well not every time… but a fair few)

heres the code for it:

if (playerenters){
  timereverywhere;
  disabledefmovement;
  showstats ;
  setstring this.spritesheet,random-sprites.gif;
  this.items={3,0,4,12,3,23,3,38,3,0,3,0};//head,pos,shirt,pos,pants,pos,shoes,pos,hair,pos,extra,pos
  showtext 300,screenwidth/2,screenheight/2-200,arial,c,Press the space bar to generate a random character;
  changeimgvis 300,4;
  timeout=0.05;
}

if (timeout){
  if (keydown2(32,true) && this.key==0){
    for (this.i=0;this.i<6;this.i++){
      showimg 301+this.i,#s(this.spritesheet),screenwidth/2-8,screenheight/2-8+this.items[this.i*2+1];
      changeimgpart 301+this.i,int(random(0,this.items[this.i*2]))*16,this.i*16,16,16;
      changeimgvis 301+this.i,4+this.i;
    }
    this.key=1;
    while (keydown2(32,true))sleep .05;
    this.key=0;
  }
  timeout=0.05;
}

The array is pretty self-explanatory, just modify the array accordingly if you add/delete items in the image.

There are pretty much 6 slots:
-Face
-Body
-Pants
-Shoes
-Hair
-Facial Item(sunnies,mustache,etc…)

Ignore my fugly graphics I just wanted to spit something out and play around with the idea more then make a finished product lol. We could get a server going along this idea if any ones keen… xialza seems pretty much screwed(doesn’t like the serverlist =( ).

Attached is the default sprite sheet and a screenie, just pop the script in a level and use a single coloured tiles all over(I used black :0)

This would be great for graal character sprites. Also, where is the hitler mustache?

This would be so much better if it used graal body and head templates and colors to generate a character, servers could use it at the start up screen.

That’s… interesting to say the least.
Make some real graphics for it, instead of the ones you got from MSPAINT and I could probably take it seriously. :stuck_out_tongue:
Script is good though.

Somethings are a bit harder if you wanted a random character generator for graal, for one all names are so inconsistent so heads could be listed as head#v(int(random(0,1000))) but not all of them are pngs so the only way to do it would be making a long string, same goes for bodies,hats,and colours. However show me a worthy project and I’ll whip one up for it lol.

no need, just make your own shit for it. lol

lol, that different name issue was one that I had when I tried making the random character thing with bodies since you’d have to have a few different strings…wouldn’t be hard, but still didn’t want to do it

Why does everything you draw come out emo? lol
That character is 100% emo. :frowning:

Why is the one guy, cross-eyed? XD.

Oh, and uh. Yay, coding!

Well I don’t know why I bothered coding this since it will probably go to waste on some never to be complete server but uhhh here it is anyway:

// NPC made by tricxta
if (playerenters){
  disabledefmovement;
  timereverywhere;
  setfocus 32,32;
  showstats ;
  this.select=0;
  setstring this.items,Hat,Head,Body,Skin,Coat,Belt,Sleeves,Shoes;
  setstring this.item0,hat1.png,hat2.png,hat3.png,hat4.png,hat5.png;
  setstring this.item1,head1.png,head2.png;
  setstring this.item2,body1.png,body2.png,body3.png,body4.png,body5.png,body6.png,body7.png,body8.png,body9.png,body10.png,body11.png,body12.png,body13.png;
  setstring this.item3,white,yellow,orange,pink,red,darkred,lightgreen,green,darkgreen,lightblue,blue,darkblue,brown,cynober,purple,darkpurple,lightgray,gray,black;
  setstring this.item4,white,yellow,orange,pink,red,darkred,lightgreen,green,darkgreen,lightblue,blue,darkblue,brown,cynober,purple,darkpurple,lightgray,gray,black;
  setstring this.item5,white,yellow,orange,pink,red,darkred,lightgreen,green,darkgreen,lightblue,blue,darkblue,brown,cynober,purple,darkpurple,lightgray,gray,black;
  setstring this.item6,white,yellow,orange,pink,red,darkred,lightgreen,green,darkgreen,lightblue,blue,darkblue,brown,cynober,purple,darkpurple,lightgray,gray,black;
  setstring this.item7,white,yellow,orange,pink,red,darkred,lightgreen,green,darkgreen,lightblue,blue,darkblue,brown,cynober,purple,darkpurple,lightgray,gray,black;
  tokenize #s(this.items);
  for (this.i=0;this.i<8;this.i++){
    showtext 300+this.i,screenwidth/2-200,(screenheight/2-100)+(this.i*30),arial,c,#t(this.i);
    changeimgvis 300+this.i,4;
    changeimgcolors 300+this.i,.5,.5,.5,1;
  }
  showtext 311,screenwidth/2,screenheight/2+200,arial,c,Press R to generate a random character;
  changeimgvis 311,4;
  timeout=0.05;
}

if (timeout){
  drawplayer();
  drawselect();
  tokenize #s(this.item#v(this.select));
  if (keydown(0) && this.select>0 && this.key==0){this.select--;this.key=1;}
  else if (keydown(2) && this.select<7 && this.key==0){this.select++;this.key=1;}
  else if (keydown(1) && strtofloat(#s(this.items#v(this.select)))>0 && this.key==0){
    setstring this.items#v(this.select),#v(strtofloat(#s(this.items#v(this.select)))-1);
    this.key=1;
  }
  else if (keydown(3) && strtofloat(#s(this.items#v(this.select)))<tokenscount-1 && this.key==0){
    setstring this.items#v(this.select),#v(strtofloat(#s(this.items#v(this.select)))+1);
    this.key=1;
  }
  else if (keydown2(82,true) && this.key==0){
    this.key=1;
    for (this.i=0;this.i<8;this.i++){
      tokenize #s(this.item#v(this.i));
      setstring this.items#v(this.i),#v(int(random(0,tokenscount)));
    }
  }
  if (!keydown(0) && !keydown(2) && !keydown(1) && !keydown(3) && this.key==1 && !keydown2(82,true))this.key=0;
  timeout=0.05;
}

function drawplayer(){
  tokenize #s(this.item0);
  setcharprop #P1,#t(strtofloat(#s(this.items0)));
  tokenize #s(this.item1);
  setcharprop #3,#t(strtofloat(#s(this.items1)));
  tokenize #s(this.item2);
  setcharprop #8,#t(strtofloat(#s(this.items2)));
  tokenize #s(this.item3);
  setcharprop #C0,#t(strtofloat(#s(this.items3)));
  tokenize #s(this.item4);
  setcharprop #C1,#t(strtofloat(#s(this.items4)));
  tokenize #s(this.item5);
  setcharprop #C4,#t(strtofloat(#s(this.items5)));
  tokenize #s(this.item6);
  setcharprop #C2,#t(strtolfoat(#s(this.items6)));
  tokenize #s(this.item7);
  setcharprop #C3,#t(strtofloat(#s(this.items7)));
  showani 1,33.5,34,2,idle,;
}

function drawselect(){
  tokenize #s(this.items);
  this.width=textwidth(1,arial,,#t(this.select))/2;
  showimg 308,character-select-arrows.png,screenwidth/2-this.width-237,screenheight/2-100+(this.select*30)-16;
  changeimgpart 308,0,0,32,32;
  changeimgvis 308,4;
  showimg 309,character-select-arrows.png,screenwidth/2+this.width-195,screenheight/2-100+(this.select*30)-16;
  changeimgpart 309,32,0,32,32;
  changeimgvis 309,4;
  showtext 310,screenwidth/2-200,(screenheight/2-100)+(this.select*30),arial,c,#t(this.select);
  changeimgvis 310,5;
}

Its pretty bulky since something when tokenizing item strings was being difficult but I managed to get something out lol.

Once again attached is a screenie of it in action and the arrows it uses. Have fun I guess lol

Why didn’t you just put the colors in this.colors and do that multiple times?

Because tric likes to do things the hard way, as he has said a million times.

I didnt use a single string for colours so you can include or exclude colours. For example if your going for a more realistic theme you wouldnt want people to set there skin to pink. Or if your going for an olden days theme you might want to only includes shades rather then actual colours.

wtf who sets their skin to pi–
OH.
Faggots.
Forgot.

herp -_-

[QUOTE=tricxta;80523]I didnt use a single string for colours so you can include or exclude colours. For example if your going for a more realistic theme you wouldnt want people to set there skin to pink. Or if your going for an olden days theme you might want to only includes shades rather then actual colours.[/QUOTE]

That’s stupid. What if I want to be a zombie or zorbi? I’d need cyan skin. What if I want to be a gnome? I’d need light-green skin. What if I wanted to use that pig head? PINK SKIN!

Then don’t remove the colour from the string…

Did you know that all colors have a numerical value?

You could have used numbers for the whole thing.

[QUOTE=Spooon;80629]
Did you know that all colors have a numerical value?

You could have used numbers for the whole thing.
[/QUOTE]

no…no I didn’t, this code is going to waste anyway…theres no point in it being as elegant as possible. Its just more concept play around rather then an end product hence why it isn’t in code gallery.