Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Put this on the MOBSPAWNERS OnUpdate
- //Working out the monsters Co ords
- var x1 = ent.getPosition().x;
- var y1 = ent.getPosition().y;
- var z1 = ent.getPosition().z;
- //Working out the players Co ords
- var x2 = player.getPosition().x;
- var y2 = player.getPosition().y;
- var z2 = player.getPosition().z;
- //Working out the difference between the player and monster
- var xx = abs(x2 - x1) * abs(x2 - x1);
- var yy = abs(y2 - y1) * abs(y2 - y1);
- var zz = abs(z2 - z1) * abs(z2 - z1);
- //Declaring variable ' D ' as the difference of the player and monster
- var D = Math.sqrt(xx + yy + zz);
- //Script for distance mechanic
- if (D > 10){
- ent.setMoveSpeed(0.1);
- }else{
- ent.setMoveSpeed(100);
- }
- function abs (n){
- if (n < 0)
- n = 0 - n;
- return n;
- }
Add Comment
Please, Sign In to add comment