[tuto] Random jump

O Ilusionista

Captain 100K
This is a code I made for my mod, to make the entity do a jump with random velocity.
Maybe there is a better version (like usin Atan to get the right angle/velocity, but I don't know how to do it yet).

Put this code into your animation script
Code:
void randomJump (int vx, int vy)
{
    // Douglas Baldan / O Ilusionista
    // version 1.0 - 23/07/13
    // makes the entity execute a jump into a random direction
      void vSelf = getlocalvar("self"); // Gets the caller
      int Xr = rand()%vx;    // Random X vel, between the chosen velocity
      int Yr = 2+rand()%vy;    // Random Y vel + 2, to ensure a vertical jump, between the chosen velocity
      if (Yr <0){            // If the Y is negative,
        Yr = Yr*-1;            // Make it positive
      }
      changeentityproperty(vSelf, "velocity", Xr, 0, Yr); // Change entity velocity
       }

Usage:
@cmd randomJump 3 4

The first value is the x velocity, the second is the y velocity.

Any improvement, feel free to share.
 
Last edited:
Thanks for share on that jump script, O! ;D

I assume this topic has to be moved to Scripting section since this topic is about script.
 
you hydra golem uses this code when he jumps?

is a cool behavior for bosses, im using my jumps on rise attack animation but random jumps are cool feature for enemies too
 
No, Golem uses the TargetLeap function, from Blood. On the beta I sent to you, I think he used just the leap function, which makes him jump based on his Z position. The newer version uses the TargetLeap, to try to stomp the char.

The Guardian enemy uses the leap without jump, just the Z logic. Take a look that it always jumps to the other "side" of the his Z position (ie, if he is at the lower part, jumps to the higher part and vice-versa).
 
Back
Top Bottom