What's new

Creating a Random Throwing Direction

iTzCascadexX

Member
Premium Supporter
Supporter
Moderator
Quality Assurance
Joined
Nov 2, 2015
Messages
164
Hey there, Cascade here with my first tutorial!

I recently implemented a random direction function to generate a throw mechanic which will really stir up a boss fight and prevent velocity from sending you in one direction only.

In order to implement this properly, I strongly suggest you use the "throw" mechanic to create the initial velocity, for example:
Code:
- throw{velocity=4;velocityY=2}

Once you've set the velocity correctly for your throw mechanic, it's relatively simple to create random direction also. There's two ways you can do this: four directions, or eight directions. (Note: these are only examples, change the values as you wish.)

4 Directions (North, East, West, South):
Code:
DirectionForward:
  Skills:
  - velocity{m=set;x=0;y=1;z=2}
DirectionRight:
  Skills:
  - velocity{m=set;x=2;y=1;z=0}
DirectionLeft:
  Skills:
  - velocity{m=set;x=-2;y=1;z=0}
DirectionBack:
  Skills:
  - velocity{m=set;x=0;y=1;z=-2}

8 Directions (North, East, West, South, North East, North West, South East, South West):
Code:
DirectionForward:
  Skills:
  - velocity{m=set;x=0;y=1;z=2}
DirectionRight:
  Skills:
  - velocity{m=set;x=2;y=1;z=0}
DirectionLeft:
  Skills:
  - velocity{m=set;x=-2;y=1;z=0}
DirectionBack:
  Skills:
  - velocity{m=set;x=0;y=1;z=-2}
DirectionForwardRight:
  Skills:
  - velocity{m=set;x=2;y=1;z=2}
DirectionForwardLeft:
  Skills:
  - velocity{m=set;x=-2;y=1;z=2}
DirectionBackRight:
  Skills:
  - velocity{m=set;x=2;y=1;z=-2}
DirectionBackLeft:
  Skills:
  - velocity{m=set;x=-2;y=1;z=-2}

Now that you've configured your directions, the meta skill call for this is really simple:
Code:
- randomskill{skills=DirectionForward,DirectionBack,DirectionRight,DirectionLeft,DirectionForwardRight,DirectionForwardLeft,DirectionBackRight,DirectionBackLeft}

The end result:
Code:
Skills:
  - throw{velocity=4;velocityY=2}
  - randomskill{skills=DirectionForward,DirectionBack,DirectionRight,DirectionLeft,DirectionForwardRight,DirectionForwardLeft,DirectionBackRight,DirectionBackLeft}

And that's it! You've now got a random direction mechanic to use for whichever mob uses a powerful throwing attack. Working versions listed below, do note that I've only tested on the latest versions of both Spigot and MM. Feel free to test this yourselves and let me know your version.

MM Version: 4.3.2
Spigot Version: 1.12.2

Thanks for reading! I hope you make something awesome out of this. :)
 
Last edited:
Top