player random attack

  • Thread starter Thread starter acidicburn83
  • Start date Start date
A

acidicburn83

Guest
does anyone know how to create a player random attack, in other words - you press attack and it chooses one from freespecial, freespecial2 or freespeacial3 ???
 
Yep, that's how to do it.
Aside of playing with rand value, we can also modify the possibility range to control which attack has higher chance.

int r = rand()%30;
      if( r > 20){
        changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW9"));
      } else if( r < -20){
        changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW4"));
      }

In this example, the chance to perform FOLLOW9 or FOLLOW4 is only about 1/6.

int r = rand()%30;
      if( r > 5){
        changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW9"));
      } else if( r < -5){
        changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW4"));
      }

In this example, the chance to perform FOLLOW9 or FOLLOW4 is about 5/12.
 
I dont think random function is that random, i get sometimes 80% more of the same results and some i never get, i have 7 remaps but only 4 appear and the other 3 never appear, not even once and i tried many many times.
 
i remember when i was at university i always used the randomize() function because it uses numbers from system clock to avoid repeat the same starting numbers the random() function
i dont know in openbor how it works
 
My friend says that "In C, the Random seed must be updated often, or you would get not so random numbers. This happens thanks to the clock on the moment of the execution. If you are on a momemnt with a high utilization rate, the chance of get a low number increases"
 
Back
Top Bottom