icejumpnrun.txt 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. rankingtable = "icejrranks";
  2. game_short = "ijr";
  3. maxplayers = 1;
  4. gamesignsmap = getScriptVar("gamesigns");
  5. gamesignloc = map.get(gamesignsmap, "icejrsign");
  6. sign.started(gamesignloc);
  7. event.load("command");
  8. event.load("player_join");
  9. event.load("player_move");
  10. event.load("living_pre_hurt");
  11. event.load("player_post_respawn");
  12. event.load("player_toss");
  13. event.load("player_logout");
  14. event.load("player_giveup");
  15. event.load("entity_click");
  16. event.load("block_break");
  17. event.load("block_place");
  18. event.load("block_click");
  19. notallowed = list.new();
  20. list.add(notallowed, "fly");
  21. list.add(notallowed, "gm");
  22. list.add(notallowed, "gamemode");
  23. list.add(notallowed, "tp");
  24. list.add(notallowed, "teleport");
  25. list.add(notallowed, "tppos");
  26. list.add(notallowed, "top");
  27. list.add(notallowed, "j");
  28. list.add(notallowed, "jumpto");
  29. gamesworld = world.get("games");
  30. sign_tag = block.getTag("minecraft:signs");
  31. checkpoints = list.new();
  32. //1.Etage
  33. list.add(checkpoints, loc.new(gamesworld, 1000, 20, -2000)); //Spawn
  34. list.add(checkpoints, loc.new(gamesworld, 987, 24, -1997));
  35. list.add(checkpoints, loc.new(gamesworld, 990, 28, -1998));
  36. list.add(checkpoints, loc.new(gamesworld, 988, 27, -1985));
  37. list.add(checkpoints, loc.new(gamesworld, 1006, 24, -1985));
  38. list.add(checkpoints, loc.new(gamesworld, 1015, 25, -2010));
  39. list.add(checkpoints, loc.new(gamesworld, 999, 35, -2013));
  40. //2.Etage
  41. list.add(checkpoints, loc.new(gamesworld, 1001, 41, -2002));
  42. list.add(checkpoints, loc.new(gamesworld, 1000, 46, -2004));
  43. list.add(checkpoints, loc.new(gamesworld, 985, 51, -2003));
  44. list.add(checkpoints, loc.new(gamesworld, 986, 50, -2000));
  45. list.add(checkpoints, loc.new(gamesworld, 989, 50, -1985));
  46. list.add(checkpoints, loc.new(gamesworld, 988, 49, -1991));
  47. list.add(checkpoints, loc.new(gamesworld, 1012, 52, -1998));
  48. //3.Etage
  49. list.add(checkpoints, loc.new(gamesworld, 998, 57, -2004));
  50. list.add(checkpoints, loc.new(gamesworld, 997, 61, -1989));
  51. list.add(checkpoints, loc.new(gamesworld, 1000, 60, -2014));
  52. list.add(checkpoints, loc.new(gamesworld, 994, 66, -1985));
  53. //4.Etage
  54. list.add(checkpoints, loc.new(gamesworld, 1000, 75, -2002));
  55. list.add(checkpoints, loc.new(gamesworld, 985, 88, -1987));
  56. list.add(checkpoints, loc.new(gamesworld, 990, 81, -2001));
  57. //5.Etage
  58. list.add(checkpoints, loc.new(gamesworld, 1000, 94, -2003));
  59. list.add(checkpoints, loc.new(gamesworld, 1000, 103, -2010));
  60. list.add(checkpoints, loc.new(gamesworld, 1007, 100, -2013));
  61. list.add(checkpoints, loc.new(gamesworld, 1009, 102, -2002));
  62. list.add(checkpoints, loc.new(gamesworld, 1012, 101, -1993));
  63. list.add(checkpoints, loc.new(gamesworld, 986, 100, -1995));
  64. //Finish
  65. list.add(checkpoints, loc.new(gamesworld, 1000, 108, -1988));
  66. @wait
  67. wait();
  68. if(event == "living_pre_hurt") {
  69. if(!isPlayer(living_entity)) {
  70. goto("wait");
  71. }
  72. player = living_entity;
  73. }
  74. if(player.hasMinigameId(player, script_id)) {
  75. ignoreGoto(event);
  76. }
  77. goto("wait");
  78. @player_join
  79. spawnlocs = list.new();
  80. for(i = 0; i < list.getSize(checkpoints); i++) {
  81. location1 = list.getIndex(checkpoints, i);
  82. location2 = loc.mod(location1, 1, 1, 1);
  83. event.addMoveData(location1, location2, -1, -1, player);
  84. list.add(spawnlocs, loc.mod(location1, 0.5, 0, 0.5));
  85. }
  86. single_uuid = player.getUuid(player);
  87. starttime = time.getMillis();
  88. player.blockCommands(player);
  89. jumpstage = ranking.getPoints(rankingtable, player.getId(player));
  90. entity.teleport(player, list.getIndex(spawnlocs, jumpstage));
  91. player.clearInventory(player);
  92. entity.addEffect(player, "minecraft:night_vision", 32760, 0, false);
  93. gosub("stage_specific");
  94. player.setGamemode(player, "adventure");
  95. player.setFly(player, false);
  96. sgoto(1, "loop");
  97. goto("wait");
  98. @block_click
  99. if(block.hasTag(sign_tag, block)) {
  100. if(block.getSign(block_loc, 2) == "Checkpoint") {
  101. entity.teleport(player, list.getIndex(spawnlocs, jumpstage));
  102. }
  103. }
  104. goto("wait");
  105. @command
  106. if(list.contains(notallowed, toLowerCase(command))) {
  107. cancel = true;
  108. msg.prefix(player, "§6Commands", "§rDie wichtigste Regel im Wettkampf: Sabotage!");
  109. }
  110. goto("wait");
  111. @player_toss
  112. living.setEquip(player, "hand", item);
  113. cancel = true;
  114. goto("wait");
  115. @entity_click
  116. @block_break
  117. @block_place
  118. cancel = true;
  119. goto("wait");
  120. @player_post_respawn
  121. entity.teleport(player, list.getIndex(spawnlocs, jumpstage));
  122. goto("wait");
  123. @living_pre_hurt
  124. damage_type = damage.getType(damage_source);
  125. if(damage_type == "fall") {
  126. cancel = true;
  127. goto("wait");
  128. }
  129. if(damage_type == "arrow") {
  130. cancel = true;
  131. goto("wait");
  132. }
  133. goto("wait");
  134. @player_move
  135. player_loc = entity.getLocation(player);
  136. x = loc.getCoord(player_loc, "bx");
  137. y = loc.getCoord(player_loc, "by");
  138. z = loc.getCoord(player_loc, "bz");
  139. loc = loc.new(gamesworld, x, y, z);
  140. index = list.getIndexOf(checkpoints, loc);
  141. if(index > jumpstage) {
  142. player.action(player, "§aCheckpoint gesetzt");
  143. msg.prefix(player, "§6Commands", concat("§r", text.number(index), ".Checkpoint erreicht"));
  144. jumpstage = index;
  145. gosub("stage_specific");
  146. }
  147. goto("wait");
  148. @stage_specific
  149. return;
  150. @loop
  151. player = player.get(single_uuid);
  152. player.setHunger(player, 20);
  153. player.setSaturation(player, 5);
  154. sgoto(200, "loop");
  155. goto("wait");
  156. @player_logout
  157. @player_giveup
  158. player.setGamemode(player, "survival");
  159. player.unblockCommands(player);
  160. endtime = time.getMillis();
  161. time = endtime - starttime;
  162. newtime = ijr.getIjrTime(player) + time;
  163. ijr.setIjrTime(player, newtime);
  164. ranking.setPoints(rankingtable, player.getId(player), jumpstage);
  165. owntime = newtime / 1000; //in Sekunden
  166. hours = text.number(math.rounddown(owntime / 3600));
  167. minutes = text.number(math.round(math.mod(owntime, 3600) / 60));
  168. minigame.statsHeader(player, "§7IceJumpnRun", "§e");
  169. minigame.statsLine(player, "§e", "Checkpoints", text.number(jumpstage));
  170. minigame.statsLine(player, "§e", "Time", concat(hours, "h ", minutes, "min"));
  171. script = script.getFromId(script_id);
  172. minigame.kickPlayer(script, player);
  173. minigame.term(script, gamesignloc);
  174. term();
  175. function ijr.setIjrTime(player_or_id, time) {
  176. config = playerdata.getGames(player_or_id);
  177. config.set(config, "icejumptime", time);
  178. config.saveAsync(config);
  179. }
  180. function ijr.getIjrTime(player_or_id) {
  181. config = playerdata.getGames(player_or_id);
  182. return config.getDouble(config, "icejumptime", 0);
  183. }