Solved Random name in anim spawn

Question that is answered or resolved.

dantedevil

Well-known member
I think woul be very useful modify this script to give a ramdom name to the enemy.

I have some bikers enemies, that they bring other companions from the motorcycle, because they come up behind.
The problem with doing this is that it always has the same name.
The idea would be to modify this script, to give you about 10 different names that you can randomly select.

Code:
anim spawn
@script
    if(frame == 1){
      void self = getlocalvar("self");
      changeentityproperty(self, "name", "black_death_gang");
    }
@end_script
    loop    0
    delay    1
    offset    82 177
    frame    data/chars/gang1/slicer/idle0.png
    frame    data/chars/gang1/slicer/idle0.png
 
Last edited:
Solution
Finally  all works ok! :D

If you don't have multiple spawn animations, you can use this right in the SPAWN animation:
Code:
	@script
  int i = rand()%41;
  void s = "";
  void self = getlocalvar("self");

  if (i < 0 )
     {i= -i;}

  if(i==0){s = "Ulric";}  else
  if(i==1){s = "Tybalt";} else
  if(i==2){s = "Borin";} else
  if(i==3){s = "Sadon";} else
  if(i==4){s = "Terrowin";} else
  if(i==5){s = "Rowan";} else
  if(i==6){s = "Forthwind";} else
  if(i==7){s = "Althalos";} else
  if(i==8){s = "Fendrel";} else
  if(i==9){s = "Brom";} else
  if(i==10){s = "Hadrian";} else
  if(i==11){s = "Crewe";} else
  if(i==12){s = "Walter De Bolbec";} else
  if(i==13){s = "Derwintwater";} else
  if(i==14){s = "Montagu";} else
  if(i==15){s = "John...
I've tried to create the script, but it does not work.
I certainly do not know enough about this.
This is what I could do ...

Code:
@script	
    if(frame==0){
      void vSelf = getlocalvar("self");
      int r = rand()%30;

       if( r > 25){
        changeentityproperty(self, "name", "kane");
      } else if( r < 20){
        changeentityproperty(self, "name", "luke");
      } else if( r < 15){
        changeentityproperty(self, "name", "kain");
      } else if( r < 10){
        changeentityproperty(self, "name", "arden");
      } else if( r < 5){
        changeentityproperty(self, "name", "bane");
      } else if( r < -5){
        changeentityproperty(self, "name", "nathan");
      } else if( r < -10){
        changeentityproperty(self, "name", "travis");
      } else if( r < -15){
        changeentityproperty(self, "name", "murdock");
      } else if( r < -20){
        changeentityproperty(self, "name", "rick");
      } else if( r < -25){
        changeentityproperty(self, "name", "axel");
    }
@end_script
 
http://www.caskeys.com/dc/tutorial-random-names/

Random names are easy money. Have a look, and let me know if you have any questions.

DC
 
O Ilusionista said:
Dante, move your function to frame 1 and it will work. Its another case of the old "frame zero bug".

Plus, there is a code for that in OpenBorStats.

Glad to know  my friend, thanks!
Thanks for the info about OpenBorStats.

I hope DC update the  link, that method look great.
 
I found this two scripts in OpenBorStats:
Code:
void namemalemedieval(int isTrue)
{
  //V0.02 Matman
  int i = rand()%41;
  void s = "";

  if (i < 0 )
     {i= -i;}


  if(i==0){s = "Ulric";}  else
  if(i==1){s = "Tybalt";} else
  if(i==2){s = "Borin";} else
  if(i==3){s = "Sadon";} else
  if(i==4){s = "Terrowin";} else
  if(i==5){s = "Rowan";} else
  if(i==6){s = "Forthwind";} else
  if(i==7){s = "Althalos";} else
  if(i==8){s = "Fendrel";} else
  if(i==9){s = "Brom";} else
  if(i==10){s = "Hadrian";} else
  if(i==11){s = "Crewe";} else
  if(i==12){s = "Walter De Bolbec";} else
  if(i==13){s = "Derwintwater";} else
  if(i==14){s = "Montagu";} else
  if(i==15){s = "John Fenwick of Wallington";} else
  if(i==16){s = "Oliver Cromwell";} else
  if(i==17){s = "Justice McKinnon";} else
  if(i==18){s = "Clifton Writingham";} else
  if(i==19){s = "Walter deGrey";} else
  if(i==20){s = "Roger de Mowbray";} else
  if(i==21){s = "Joseph Rowntree";} else
  if(i==22){s = "Geoffrey Chaucer";} else
  if(i==23){s = "William of Wykeham";} else
  if(i==24){s = "Francis Drake";} else
  if(i==25){s = "Simon de Montfort";} else
  if(i==26){s = "John of Gaunt";} else
  if(i==27){s = "William of Orange";} else
  if(i==28){s = "Cornwallis";} else
  if(i==29){s = "Edmund Cartwright";} else
  if(i==30){s = "Charles the Bald";} else
  if(i==31){s = "Benedict";} else
  if(i==32){s = "Gregory";} else
  if(i==33){s = "Peter";} else
  if(i==34){s = "Henry";} else
  if(i==35){s = "Frederick";} else
  if(i==36){s = "Walter";} else
  if(i==37){s = "Thomas";} else
  if(i==38){s = "Arthur";} else
  if(i==39){s = "Bryce";} else
  if(i==40){s = "Donald";} else
  if(i==41){s = "Leofrick";}

  if (s=="") { s = namemalemedieval(1); }

  return s;
}

Code:
void namefemalemedieval(int isTrue)
{
  //V0.02 Matman
  int i = rand()%45;
  void s = "";
  if (i < 0 )
     {i= -i;}


  if(i==0){s = "Alys";}  else
  if(i==1){s = "Ayleth";} else
  if(i==2){s = "Anastas";} else
  if(i==3){s = "Alianor";} else
  if(i==4){s = "Cedany";} else
  if(i==5){s = "Ellyn";} else
  if(i==6){s = "Helewys";} else
  if(i==7){s = "Malkyn";} else
  if(i==8){s = "Peronell";} else
  if(i==9){s = "Sybbyl";} else
  if(i==10){s = "Ysmay";} else
  if(i==11){s = "Thea";} else
  if(i==12){s = "Jacquelyn";} else
  if(i==13){s = "Countess Amelia";} else
  if(i==14){s = "Gloriana";} else
  if(i==15){s = "Good Queen Bess";} else
  if(i==16){s = "Catherine of Aragon";} else
  if(i==17){s = "Anne of Cleves";} else
  if(i==18){s = "Mary, Queen of Scots";} else
  if(i==19){s = "Mary of Guise";} else
  if(i==20){s = "Arabella";} else
  if(i==21){s = "Elizabeth";} else
  if(i==22){s = "Hildegard";} else
  if(i==23){s = "Brunhild";} else
  if(i==24){s = "Adelaide";} else
  if(i==25){s = "Alice";} else
  if(i==26){s = "Beatrix";} else
  if(i==27){s = "Cristiana";} else
  if(i==28){s = "Eleanor";} else
  if(i==29){s = "Emeline";} else
  if(i==30){s = "Isabel";} else
  if(i==31){s = "Juliana";} else
  if(i==32){s = "Margaret";} else
  if(i==33){s = "Matilda";} else
  if(i==34){s = "Mirabelle";} else
  if(i==35){s = "Rose";} else
  if(i==36){s = "Helena";} else
  if(i==37){s = "Guinevere";} else
  if(i==38){s = "Isolde";} else
  if(i==39){s = "Maerwynn";} else
  if(i==40){s = "Muriel";} else
  if(i==41){s = "Winifred";} else
  if(i==42){s = "Godiva";} else
  if(i==43){s = "Catrain";} else
  if(i==44){s = "Angmar";} else
  if(i==45){s = "Gussalen";}

  if (s=="") { s = namefemalemedieval(1); }

  return s;
}

But i don´t know how use it.
What should I put here? (int isTrue)
 
Sorry, I was on my phone and didn't read all the code.

If you don't have multiple spawn animations, you can use this right in the SPAWN animation:
Code:
	@script
  int i = rand()%41;
  void s = "";
  void self = getlocalvar("self");

  if (i < 0 )
     {i= -i;}

  if(i==0){s = "Ulric";}  else
  if(i==1){s = "Tybalt";} else
  if(i==2){s = "Borin";} else
  if(i==3){s = "Sadon";} else
  if(i==4){s = "Terrowin";} else
  if(i==5){s = "Rowan";} else
  if(i==6){s = "Forthwind";} else
  if(i==7){s = "Althalos";} else
  if(i==8){s = "Fendrel";} else
  if(i==9){s = "Brom";} else
  if(i==10){s = "Hadrian";} else
  if(i==11){s = "Crewe";} else
  if(i==12){s = "Walter De Bolbec";} else
  if(i==13){s = "Derwintwater";} else
  if(i==14){s = "Montagu";} else
  if(i==15){s = "John Fenwick of Wallington";} else
  if(i==16){s = "Oliver Cromwell";} else
  if(i==17){s = "Justice McKinnon";} else
  if(i==18){s = "Clifton Writingham";} else
  if(i==19){s = "Walter deGrey";} else
  if(i==20){s = "Roger de Mowbray";} else
  if(i==21){s = "Joseph Rowntree";} else
  if(i==22){s = "Geoffrey Chaucer";} else
  if(i==23){s = "William of Wykeham";} else
  if(i==24){s = "Francis Drake";} else
  if(i==25){s = "Simon de Montfort";} else
  if(i==26){s = "John of Gaunt";} else
  if(i==27){s = "William of Orange";} else
  if(i==28){s = "Cornwallis";} else
  if(i==29){s = "Edmund Cartwright";} else
  if(i==30){s = "Charles the Bald";} else
  if(i==31){s = "Benedict";} else
  if(i==32){s = "Gregory";} else
  if(i==33){s = "Peter";} else
  if(i==34){s = "Henry";} else
  if(i==35){s = "Frederick";} else
  if(i==36){s = "Walter";} else
  if(i==37){s = "Thomas";} else
  if(i==38){s = "Arthur";} else
  if(i==39){s = "Bryce";} else
  if(i==40){s = "Donald";} else
  if(i==41){s = "Leofrick";}
  changeentityproperty(self, "name", s);
@end_script

Or, you can use it as a function on a onspawnsrcript file - for example, randomname.c
Code:
void randomname()
{
  //V0.02 Matman
  int i = rand()%41;
  void s = "";
  void self = getlocalvar("self");

  if (i < 0 )
     {i= -i;}

  if(i==0){s = "Ulric";}  else
  if(i==1){s = "Tybalt";} else
  if(i==2){s = "Borin";} else
  if(i==3){s = "Sadon";} else
  if(i==4){s = "Terrowin";} else
  if(i==5){s = "Rowan";} else
  if(i==6){s = "Forthwind";} else
  if(i==7){s = "Althalos";} else
  if(i==8){s = "Fendrel";} else
  if(i==9){s = "Brom";} else
  if(i==10){s = "Hadrian";} else
  if(i==11){s = "Crewe";} else
  if(i==12){s = "Walter De Bolbec";} else
  if(i==13){s = "Derwintwater";} else
  if(i==14){s = "Montagu";} else
  if(i==15){s = "John Fenwick of Wallington";} else
  if(i==16){s = "Oliver Cromwell";} else
  if(i==17){s = "Justice McKinnon";} else
  if(i==18){s = "Clifton Writingham";} else
  if(i==19){s = "Walter deGrey";} else
  if(i==20){s = "Roger de Mowbray";} else
  if(i==21){s = "Joseph Rowntree";} else
  if(i==22){s = "Geoffrey Chaucer";} else
  if(i==23){s = "William of Wykeham";} else
  if(i==24){s = "Francis Drake";} else
  if(i==25){s = "Simon de Montfort";} else
  if(i==26){s = "John of Gaunt";} else
  if(i==27){s = "William of Orange";} else
  if(i==28){s = "Cornwallis";} else
  if(i==29){s = "Edmund Cartwright";} else
  if(i==30){s = "Charles the Bald";} else
  if(i==31){s = "Benedict";} else
  if(i==32){s = "Gregory";} else
  if(i==33){s = "Peter";} else
  if(i==34){s = "Henry";} else
  if(i==35){s = "Frederick";} else
  if(i==36){s = "Walter";} else
  if(i==37){s = "Thomas";} else
  if(i==38){s = "Arthur";} else
  if(i==39){s = "Bryce";} else
  if(i==40){s = "Donald";} else
  if(i==41){s = "Leofrick";}
  changeentityproperty(self, "name", s);
}

I've tested and it works.
 
Thanks my friend!

The first option, use in the SPAWN animation works great.

But the second option, use it as a function on a onspawnsrcript, not work.

The Log say: "There's an exception while executing script 'onspawnscript' data/chars/.....
 
Finally  all works ok! :D

If you don't have multiple spawn animations, you can use this right in the SPAWN animation:
Code:
	@script
  int i = rand()%41;
  void s = "";
  void self = getlocalvar("self");

  if (i < 0 )
     {i= -i;}

  if(i==0){s = "Ulric";}  else
  if(i==1){s = "Tybalt";} else
  if(i==2){s = "Borin";} else
  if(i==3){s = "Sadon";} else
  if(i==4){s = "Terrowin";} else
  if(i==5){s = "Rowan";} else
  if(i==6){s = "Forthwind";} else
  if(i==7){s = "Althalos";} else
  if(i==8){s = "Fendrel";} else
  if(i==9){s = "Brom";} else
  if(i==10){s = "Hadrian";} else
  if(i==11){s = "Crewe";} else
  if(i==12){s = "Walter De Bolbec";} else
  if(i==13){s = "Derwintwater";} else
  if(i==14){s = "Montagu";} else
  if(i==15){s = "John Fenwick of Wallington";} else
  if(i==16){s = "Oliver Cromwell";} else
  if(i==17){s = "Justice McKinnon";} else
  if(i==18){s = "Clifton Writingham";} else
  if(i==19){s = "Walter deGrey";} else
  if(i==20){s = "Roger de Mowbray";} else
  if(i==21){s = "Joseph Rowntree";} else
  if(i==22){s = "Geoffrey Chaucer";} else
  if(i==23){s = "William of Wykeham";} else
  if(i==24){s = "Francis Drake";} else
  if(i==25){s = "Simon de Montfort";} else
  if(i==26){s = "John of Gaunt";} else
  if(i==27){s = "William of Orange";} else
  if(i==28){s = "Cornwallis";} else
  if(i==29){s = "Edmund Cartwright";} else
  if(i==30){s = "Charles the Bald";} else
  if(i==31){s = "Benedict";} else
  if(i==32){s = "Gregory";} else
  if(i==33){s = "Peter";} else
  if(i==34){s = "Henry";} else
  if(i==35){s = "Frederick";} else
  if(i==36){s = "Walter";} else
  if(i==37){s = "Thomas";} else
  if(i==38){s = "Arthur";} else
  if(i==39){s = "Bryce";} else
  if(i==40){s = "Donald";} else
  if(i==41){s = "Leofrick";}
  changeentityproperty(self, "name", s);
@end_script

In a onspawnsrcript file - for example, randomname.c
Code:
void main()
{
  //V0.02 Matman
  int i = rand()%41;
  void s = "";
  void self = getlocalvar("self");

  if (i < 0 )
     {i= -i;}

  if(i==0){s = "Ulric";}  else
  if(i==1){s = "Tybalt";} else
  if(i==2){s = "Borin";} else
  if(i==3){s = "Sadon";} else
  if(i==4){s = "Terrowin";} else
  if(i==5){s = "Rowan";} else
  if(i==6){s = "Forthwind";} else
  if(i==7){s = "Althalos";} else
  if(i==8){s = "Fendrel";} else
  if(i==9){s = "Brom";} else
  if(i==10){s = "Hadrian";} else
  if(i==11){s = "Crewe";} else
  if(i==12){s = "Walter De Bolbec";} else
  if(i==13){s = "Derwintwater";} else
  if(i==14){s = "Montagu";} else
  if(i==15){s = "John Fenwick of Wallington";} else
  if(i==16){s = "Oliver Cromwell";} else
  if(i==17){s = "Justice McKinnon";} else
  if(i==18){s = "Clifton Writingham";} else
  if(i==19){s = "Walter deGrey";} else
  if(i==20){s = "Roger de Mowbray";} else
  if(i==21){s = "Joseph Rowntree";} else
  if(i==22){s = "Geoffrey Chaucer";} else
  if(i==23){s = "William of Wykeham";} else
  if(i==24){s = "Francis Drake";} else
  if(i==25){s = "Simon de Montfort";} else
  if(i==26){s = "John of Gaunt";} else
  if(i==27){s = "William of Orange";} else
  if(i==28){s = "Cornwallis";} else
  if(i==29){s = "Edmund Cartwright";} else
  if(i==30){s = "Charles the Bald";} else
  if(i==31){s = "Benedict";} else
  if(i==32){s = "Gregory";} else
  if(i==33){s = "Peter";} else
  if(i==34){s = "Henry";} else
  if(i==35){s = "Frederick";} else
  if(i==36){s = "Walter";} else
  if(i==37){s = "Thomas";} else
  if(i==38){s = "Arthur";} else
  if(i==39){s = "Bryce";} else
  if(i==40){s = "Donald";} else
  if(i==41){s = "Leofrick";}
  changeentityproperty(self, "name", s);
}

Thanks my friend (O Ilusionista),  I could not have done it without you.
 
Solution
Back
Top Bottom