herobrine.txt 1.3 KB

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