randomly dizzy enemies??

NED

Well-known member
I would like enemies to play a short stun/dizzy-like after rising from any fall.
This have to appear randomly perhaps 35% of times.

I know random settings are not easy to do in Openbor, but how can I add it?
Any exemple of how to implement such a feature.

Thanks
 
You can insert script in rise animation with random switch and change to freespecial or follow (dizzy)animation
Here is my rise animation which changes to different frames based on random number, you can use and modify this to change it to different animation from rise.if you want to get enemy back to idle from dizzy just put "idle    1" before last frame in dizzy anim
anim rise
loop 0
offset 98 177
bbox 0 0 0 0 0
delay 35
      @script
    void self = getlocalvar("self");
    if( frame == 0){
      int r = rand()%30;
      if( r > 11){
        changeentityproperty(self, "animpos", 1);
      } else if( r < -10){
        changeentityproperty(self, "animpos", 2);
      } else if( r < 0){
        changeentityproperty(self, "animpos", 0);
      } else if( r > 0){
        changeentityproperty(self, "animpos", 3);
      }
    }
@end_script
frame data/chars/trem/fall7.gif
frame data/chars/trem/fall7.gif
frame data/chars/trem/fall7.gif
frame data/chars/trem/fall7.gif
delay 4
frame data/chars/trem/rise1.gif
frame data/chars/trem/rise2.gif
frame data/chars/trem/rise3.gif
frame data/chars/trem/rise4.gif
frame data/chars/trem/rise5.gif
 
For the rise part (only),
Is this OK?

anim rise
loop 0
offset 96 177
bbox 0 0 0 0
delay 15#11



      @script
    void self = getlocalvar("self");
    if( frame == 0){
      int r = rand()%30;
      if( r > 11){
        changeentityproperty(self, "animpos", 1);
      } else if( r < -10){
        changeentityproperty(self, "animpos", 2);
      } else if( r < 0){
        changeentityproperty(self, "animpos", 0);
      } else if( r > 0){
        changeentityproperty(self, "animpos", 3);
      }
    }
  @end_script 



frame data/chars/mex/rise1.gif
delay 18
frame data/chars/mex/rise2.gif
delay 18
frame data/chars/mex/rise3.gif


I'm not sure to understand these values :
changeentityproperty(self, "animpos", 1);
      } else if( r < -10){
 
There are couple ways to do this, bWWd uses single animation method for multiple fallen times.

You can use different animation for dizzy animation like this:

anim  rise
  loop  0
  offset  96 177
  bbox  0 0 0 0
  delay  15#11
      @script
    void self = getlocalvar("self");
    if( frame == 0){
      int r = rand()%30;
      if( r >= 9){
        changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW1"));
      }
    }
  @end_script 
  frame  data/chars/mex/rise1.gif
  delay  18
  frame  data/chars/mex/rise2.gif
  delay  18
  frame  data/chars/mex/rise3.gif

anim  follow1
  offset  96 177
  bbox  0 0 0 0
  delay  15
  frame  data/chars/mex/dizzy1.gif
  delay  18
  frame  data/chars/mex/dizzy2.gif

The script in RISE has about 35%chance to change animation to FOLLOW1, which is dizzy animation. You can edit FOLLOW1 animation to anything you want.
 
seems to work, but I can't understand exatly what mean these values

      int r = rand()%30;
      if( r >= 9){

How these 2 crecreates 35% of probability? (sorry for being dumb)

Also, what decides the frame of rise anim when the dizzy anim can be played?
 
What animpos means? I've searched on both manuals but there is no mention to it.

It is entity property which means frame of animation. Just reminder, 1st frame is counted as 0, 2nd frame as 1 and so on.

How these 2 crecreates 35% of probability?

First of all, rand()%30 gets random value from -30 to 30. Since r (variable to hold value) is integer, the result of rand function is integer i.e -30, -29, ... , 29, 30

If you count how many possible values you may get, there are 61 values.
To define randomness to 35% as you requested, we need to define range of values for r from 61 possible values.
So how many accepted values from those 61 values?
To simplify, let's round 61 to 60.

x/60 = 35/100

x = 60*0.35 = 21

That means we need to 'take' just 21 of those 61 possible values. There are multiple ways to do that but the simplest way is to take range of accepted values.
For instance, let's take positive values from 30 (highest possible value) to below. To take 21 values, that means the lowest limit is 30-21=9

So the accepted range is r>9.
I made typo in script above but it's slight error and hard to see in game.

what decides the frame of rise anim when the dizzy anim can be played?

The script I posted above doesn't modify frame.
 
Back
Top Bottom