herobrine.txt 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. event.load("block_break");
  2. event.load("human_hurt");
  3. event.load("entity_join");
  4. herobrines = list.new();
  5. msg("dev", "§bHerobrine §rloaded.");
  6. @wait
  7. wait();
  8. if(event == "entity_join") {
  9. if(entity.getType(entity) != "human") {
  10. goto("wait");
  11. }
  12. if(entity.getName(entity) != "Herobrine") {
  13. goto("wait");
  14. }
  15. if(list.contains(herobrines, entity)) {
  16. goto("wait");
  17. }
  18. entity.remove(entity);
  19. goto("wait");
  20. }
  21. if(event == "human_hurt") {
  22. entity_name = entity.getName(human);
  23. if(list.contains(herobrines, human)) {
  24. if(entity == null) {
  25. goto("wait");
  26. }
  27. if(!isLiving(entity)) {
  28. goto("wait");
  29. }
  30. living.damage(entity, 10, damage.get("thorns", human));
  31. }
  32. goto("wait");
  33. }
  34. if(event == "block_break") {
  35. player_loc = entity.getLocation(player);
  36. world_name = world.getName(loc.getWorld(player_loc));
  37. if(!world.isSurvName(world_name)) {
  38. goto("wait");
  39. }
  40. r = math.random(1, 2000);
  41. if(r == 1) {
  42. spawnHerobrine(player);
  43. }
  44. goto("wait");
  45. }
  46. goto("wait");
  47. function spawnHerobrine(player) {
  48. player_loc = entity.getLocation(player);
  49. dist = math.random(4, 20);
  50. alpha = math.random(0, 360);
  51. alpha *= math.pi() / 180;
  52. x = math.round(math.sin(alpha) * dist) + 0.5;
  53. z = math.round(math.cos(alpha) * dist) + 0.5;
  54. y = 255;
  55. hero_loc = loc.mod(player_loc, x, y, z);
  56. while(block.isAir(hero_loc)) {
  57. loc.setY(hero_loc, y);
  58. y--;
  59. }
  60. loc.addY(hero_loc, 1);
  61. ent = human.spawn(hero_loc);
  62. list.add($herobrines, ent);
  63. human.setSkin(ent, "herobrine");
  64. entity.setName(ent, "Herobrine");
  65. sgoto(400, "deleteHerobrine");
  66. }
  67. @deleteHerobrine
  68. ent = list.getIndex(herobrines, 0);
  69. list.removeIndex(herobrines, 0);
  70. entity.remove(ent);
  71. goto("wait");