random sound

Gurtag

Active member
hey ppl, new here, wanted to ask if there is a way to randomize 2 or more sounds of an attack animation.
for example first time i perform attack plays sond 1 then next time play sound2 or full random if it is posible
 
thanks a lot for the help man, though now that you mention it i didnt know something like that would require scripts, know nothing about that, just learning the basics things yet, also sorry for my bad english.
 
thanks a lot man your a god send, will try it out later, storm pass over last night and half of my house trees are on the floor now have to go do some cuting  :-\
 
sorry for the long delay had not much free time lately, now followed your instructions and it worked like charm, thanks a lot for the imput, btw what vercion of openborstats would you recommend? i use it a lot as it simplifies a lot of tasks, however the latest vercion doesnt display boxes correctly on the below preview of frames, nevertheless i realy like the entity overlay which sadly the vercion i use 0.53 seems to lack of.
 
Gurtag nsw25
Something you should be aware while using that code (I use it btw): those sounds will be loaded only when the script is triggered, instead of being pre-loaded with the entities when they are loaded into the memory.
So, in some cases, you can see a micro loading while you play.

And from that code, I would take off the "/sounds" part, so you can get all the sounds you want from the game folder

Code:
void randSound(char s1,char s2,char s3)
{
   int r = rand()%300;
   char sound;
   if (r<=-100)
   {
      sound=s1;
   }else if(r<=100){
      sound=s2;
   }else{
      sound=s3;
   }
   playSound("data/sounds/"+sound);
}
void randSound2(char s1,char s2,char s3,char s4,char s5,char s6)
{
   int      r      =   rand()%300+300;
   char   sound   =   "";

   if (r<100){
      sound=s1;
   }else if(r<200){
      sound=s2;
   }else if(r<300){
      sound=s3;
   }else if(r<400){
      sound=s4;
   }else if(r<500){
      sound=s5;
   }else if(r<600){
      sound=s6;
   }
   playSound("data/"+sound);
}
void playSound(void file)
{
   if(!file||file==""){return;}else{}
   int sfx=loadsample(file);
   playsample(sfx, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
}

So it would be
@cmd randSound2 "sounds/doh1.wav" "sounds/hmrpain1.wav" "sounds/hmrpain2.wav" "sounds/hmrpain3.wav" "sounds/hmrpain4.wav" "sounds/hmrscream.wav"
 
thanks for the advise, it will come handy as i have lots of sound on otter folders, about the script loading could you explain further as it may be related to an issue i am having now, if i go in a new game works fine but if i quit/save and load that save whenever i perform the animation with the script it crashes the game, any idea of what could be the problem? or is just how the script works? also any advise of what i mentioned about the openborstats vercion?
 
if i go in a new game works fine but if i quit/save and load that save whenever i perform the animation with the script it crashes the game, any idea of what could be the problem?
This is a bug that happens only on android (at least, for me) it was already reported. I need to track down WHICH version specifically had started this.

About OpenBORstats, get the most recent one.
 
i see, then is just a bug, however i am using windows and openbor 3.0.3769.
about openborstats, the latest vercion is the one with the missaligned boxes se below for what i mean.

thump_9882920openborstats.jpg
 
Back
Top Bottom