hungergames.txt 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. event.load("player_hurt");
  2. event.load("block_click");
  3. event.load("player_leave");
  4. event.load("player_giveup");
  5. no_quest_msg = true;
  6. started = false;
  7. list.new("all");
  8. list.new("spectators");
  9. barrierblock = read.item("BARRIER");
  10. airblock = read.item("AIR");
  11. gamename = "§9HungerGames";
  12. counterindex = 0; //Laufvariable zum Mitzählen, welche Zeit des Startcountdowns als nächsten an der Reihe ist
  13. list.new("starttimes"); //Liste zum schnellen Varrieren des Startcountdowns
  14. list.add(starttimes, 20);
  15. list.add(starttimes, 15);
  16. list.add(starttimes, 10);
  17. list.add(starttimes, 5);
  18. list.add(starttimes, 4);
  19. list.add(starttimes, 3);
  20. list.add(starttimes, 2);
  21. list.add(starttimes, 1);
  22. list.add(starttimes, 0);
  23. @lobby
  24. if(list.getSize(all) >= maxplayers) {
  25. player.speak(player, gamename, "§rDiese Map ist bereits voll.");
  26. player.kick(player);
  27. goto("checklobby");
  28. }
  29. player.speak("all", gamename, concat("§6", player_name, " §rhat das Spiel betreten"));
  30. list.add(all, player_name);
  31. block.setSign(gamesignloc, 2, concat(list.getSize(all), "/", maxplayers));
  32. command("clear ", player_name);
  33. entity.setHealth(player, 20);
  34. player.setHunger(player, 20);
  35. player.setSaturation(player, 5);
  36. entity.teleport(player, lobbyloc);
  37. display.reset(player);
  38. display.add(player, 0, gamename);
  39. display.add(player, 1, "§7Map:");
  40. display.add(player, 2, concat("§b", mapname));
  41. display.add("all", 3, concat("§7Spieler: §r", concat(list.getSize(all), "/", gamesize)));
  42. display.add(player, 4, teams);
  43. setVar(concat(player_name, "hgkills"), 0);
  44. sgv(player_name, "hgplayedgames", add(ggv(player_name, "hgplayedgames"), 1));
  45. if(ggv(player, "hgplayedgames") == null) {
  46. sgv(player, "hgplayedgames", 0);
  47. }
  48. if(ggv(player, "hgwongames") == null) {
  49. sgv(player, "hgwongames", 0);
  50. }
  51. player.speak(player_name, gamename, "§rDu befindest dich in der ", gamename, " §rLobby.");
  52. if(!started) {
  53. if(list.getSize(all) >= playersneeded) {
  54. goto("startgame");
  55. }
  56. @waiting
  57. started = false;
  58. counterindex = 0;
  59. waitfor = playersneeded - list.getSize(all);
  60. player.speak("all", gamename, "§rEs wird auf ", concat("§6", waitfor), " §rSpieler gewartet.");
  61. }
  62. @checklobby
  63. wait();
  64. if(event == "player_join") {
  65. goto("lobby");
  66. }
  67. if(event == "player_leave" || event == "player_giveup") {
  68. goto("leavelobby");
  69. }
  70. if(event == "block_click" || event == "player_hurt") {
  71. cancel = true;
  72. goto("checklobby");
  73. }
  74. goto("checklobby");
  75. @leavelobby
  76. list.remove(all, player_name);
  77. block.setSign(gamesignloc, 2, concat(list.getSize(all), "/", maxplayers));
  78. if(list.getSize(all) < playersneeded) {
  79. block.setSign(gamesignloc, 3, "§2Wartet");
  80. }
  81. entity.teleport(player, gamesworldloc);
  82. display.reset(player);
  83. display.add("all", 3, concat("§7Spieler: §r", concat(list.getSize(all), "/", gamesize)));
  84. entity.setHealth(player, 20);
  85. player.setHunger(player, 20);
  86. player.setSaturation(player, 5);
  87. player.kick(player);
  88. goto("checklobby");
  89. @startgame
  90. if(list.getSize(all) < playersneeded) {
  91. goto("waiting");
  92. }
  93. started = true;
  94. block.setSign(gamesignloc, 3, "§bStartet");
  95. noticetime = list.getIndex(starttimes, counterindex);
  96. if(noticetime == 5) {
  97. for(i = 0; i <= list.getSize(all) - 1; i++) {
  98. title.setSub(read.player(list.getIndex(all, i)), mapname);
  99. title.send(read.player(list.getIndex(all, i)), gamename);
  100. }
  101. }
  102. if(noticetime == 0) {
  103. goto("finalstart");
  104. }
  105. noticetime2 = list.getIndex(starttimes, inc("counterindex"));
  106. if(noticetime == 1) {
  107. player.speak("all", gamename, concat("§rDas Spiel startet in §6", noticetime, " §rSekunde."));
  108. } else {
  109. player.speak("all", gamename, concat("§rDas Spiel startet in §6", noticetime, " §rSekunden."));
  110. }
  111. stime = (noticetime - noticetime2) * 20;
  112. sgoto(stime, "startgame");
  113. for(i = 0; i <= list.getSize(all) - 1; i++) {
  114. p = read.player(list.getIndex(all, i));
  115. player.playSound(p, "block.note.bass");
  116. }
  117. goto("checklobby");
  118. @finalstart
  119. no_join = true;
  120. player.speak("all", gamename, "§rDas Spiel läuft.");
  121. block.setSign(gamesignloc, 2, concat(list.getSize(all), "/", maxplayers));
  122. block.setSign(gamesignloc, 3, "§6Läuft");
  123. map.new("lifes");
  124. map.new("usedeffects");
  125. map.new("lastdamage");
  126. list.new("resetlist");
  127. for(i = 0; i <= list.getSize(all) - 1; i++) {
  128. pname = list.getIndex(all, i);
  129. p = read.player(pname);
  130. entity.teleport(p, list.getIndex(startlocs, i));
  131. if(player.isSurvival(p)) {
  132. if(player.isAdventure(p)) {
  133. command("gamemode survival ", pname);
  134. }
  135. } else {
  136. command("gamemode survival ", pname);
  137. }
  138. if(player.hasFly(p)) {
  139. command("fly ", pname, " off");
  140. }
  141. setVar(concat(pname, "knocked"), 0);
  142. player.giveItem(p, knockback1);
  143. map.add(lastdamage, pname, null);
  144. map.add(lifes, pname, 5);
  145. map.add(usedeffects, pname, 0);
  146. }
  147. display.reset("all");
  148. display.add("all", 0, "§9HungerGames");
  149. display.add("all", 1, teams);
  150. display.add("all", 2, "§eSpieler verbleibend: §b", list.getSize(all));
  151. for(i = 0; i <= list.getSize(spawns) - 1; i++) {
  152. block.set(loc.mod(list.getIndex(spawns, i), 1, 0, 0), barrierblock);
  153. block.set(loc.mod(list.getIndex(spawns, i), -1, 0, 0), barrierblock);
  154. block.set(loc.mod(list.getIndex(spawns, i), 0, 0, 1), barrierblock);
  155. block.set(loc.mod(list.getIndex(spawns, i), 0, 0, -1), barrierblock);
  156. block.set(loc.mod(list.getIndex(spawns, i), 0, 2, 0), barrierblock);
  157. }
  158. //Code unten alt
  159. @fillchests
  160. setVar("i", 0);
  161. @filllabel
  162. block.clone(list.getIndex(chests, math.random(0, sub(list.getSize(aimchests), 1))), list.getIndex(aimchests, i));
  163. if(less(inc("i"), list.getSize(chests))) goto("filllabel");
  164. setVar("i", -1);
  165. while(less(inc("i"), list.getSize(all))) {
  166. setVar("p", read.player(list.getIndex(all, i)));
  167. title.clear(p);
  168. title.setTime(p, 0, 20, 0);
  169. }
  170. @checkstart
  171. wait();
  172. if(event == "player_leave" || event == "player_giveup") {
  173. goto("leavegame");
  174. }
  175. if(event == "block_click" || event == "player_hurt") {
  176. cancel = true;
  177. goto("checkstart");
  178. }
  179. goto("checkstart");
  180. @finalstart
  181. setVar("i", -1);
  182. while(less(inc("i"), list.getSize(spawns))) {
  183. block.set(loc.mod(list.getIndex(spawns, i), 1, 0, 0), airblock);
  184. block.set(loc.mod(list.getIndex(spawns, i), -1, 0, 0), airblock);
  185. block.set(loc.mod(list.getIndex(spawns, i), 0, 0, 1), airblock);
  186. block.set(loc.mod(list.getIndex(spawns, i), 0, 0, -1), airblock);
  187. block.set(loc.mod(list.getIndex(spawns, i), 0, 2, 0), airblock);
  188. }
  189. setVar("i", -1);
  190. while(less(inc("i"), list.getSize(all))) {
  191. setVar("p", read.player(list.getIndex(all, i)));
  192. title.setTime(p, 20, 0, 20);
  193. title.send(p, "§cKeine Schutzzeit");
  194. }
  195. setVar("starttime", time.get());
  196. event.load("player-death");
  197. event.load("player-respawn");
  198. event.unload("block-click");
  199. @startloop
  200. sgoto(100, "loop");
  201. @checkgame
  202. wait();
  203. if(or(equal(event, "block-place"), equal(event, "block-break"))) {
  204. setVar("cancel", true);
  205. }
  206. if(and(equal(event, "player-death"), equal(player-killed, true), invert(list.contains(spectators, player-name)))) {
  207. goto("death");
  208. }
  209. //if(event, ==, player-respawn, then, sgoto, 1, respawn)
  210. if(equal(event, "player-leave")) {
  211. goto("leavegame");
  212. }
  213. goto("checkgame");
  214. @loop
  215. if(equal(list.getSize(spectators), 0)) goto("startloop");
  216. setVar("i", -1);
  217. while(less(inc("i"), list.getSize(spectators))) {
  218. setVar("p", read.player(list.getIndex(spectators, i)));
  219. if(greater(loc.distance(entity.getLocation(p), middleloc), radius)) {
  220. entity.teleport(p, middleloc);
  221. }
  222. }
  223. goto("startloop");
  224. @respawn
  225. command("gamemode 3 ", player-name);
  226. entity.teleport(player, middleloc);
  227. if(invert(list.contains(spectators, player-name))) list.add(spectators, player-name);
  228. goto("checkgame");
  229. @death
  230. command("clear ", player-name);
  231. if(notequal(sec-player-name, null)) goto("deathbyplayer");
  232. @singledeath
  233. player.speak("all", "§9HungerGames", "§8", player-name, "§e ist gestorben.");
  234. list.remove(all, player-name);
  235. player.respawn(player);
  236. sgoto(2, "checkplayability");
  237. sgoto(1, "respawn");
  238. goto("checkgame");
  239. @deathbyplayer
  240. if(equal(player-name, sec-player-name)) goto("singledeath");
  241. player.speak("all", "§9HungerGames", "§8", player-name, "§e ist durch §8", sec-player-name, "§e gestorben.");
  242. sgv(sec-player-name, "hgkills", add(ggv(sec-player-name, "hgkills"), 1));
  243. inc(concat(sec-player-name, "kills"));
  244. list.remove(all, player-name);
  245. setVar("sec-player-name", null);
  246. player.respawn(player);
  247. sgoto(2, "checkplayability");
  248. sgoto(1, "respawn");
  249. goto("checkgame");
  250. @checkplayability
  251. if(lessequal(list.getSize(all), 1)) {
  252. goto("win");
  253. } else() {
  254. player.speak("all", "§9HungerGames", "§eEs sind noch §b", list.getSize(all), " §eSpieler im Spiel.");
  255. sb.add("all", 1, "§eSpieler verbleibend: §b", list.getSize(all));
  256. }
  257. goto("checkgame");
  258. @win
  259. setVar("endtime", time.get());
  260. setVar("pname", list.getIndex(all, 0));
  261. setVar("p", read.player(pname));
  262. player.speak("all", "§9HungerGames", "§8", pname, "§e hat gewonnen.");
  263. sgv(pname, "hgwongames", add(ggv(pname, "hgwongames"), 1));
  264. gmap.add("hgranks", player.getUuid(p), ggv(pname, "hgwongames"));
  265. quest.playersToList(all);
  266. setVar("i", -1);
  267. while(less(inc("i"), list.getSize(spectators))) {
  268. setVar("pname", list.getIndex(spectators, i));
  269. list.remove(spectators, pname);
  270. list.add(all, pname);
  271. command("gamemode SURVIVAL ", pname);
  272. }
  273. removeVar("spectators");
  274. gmap.toTable("hgrankstable", "hgranks");
  275. table.setSortColumn(hgrankstable, 1);
  276. table.sort(hgrankstable);
  277. table.reverse(hgrankstable);
  278. table.setSortColumn(hgrankstable, 0);
  279. setVar("i", -1);
  280. while(less(inc("i"), list.getSize(all))) {
  281. setVar("pname", list.getIndex(all, i));
  282. setVar("p", read.player(pname));
  283. sb.reset(p);
  284. entity.teleport(p, gamesworldloc);
  285. entity.setHealth(p, 20);
  286. player.setHunger(p, 20);
  287. player.setSaturation(p, 5);
  288. command("clear ", pname);
  289. player.speak(p, "§9HungerGames", "§7-= §eStatistik dieses Spiels §7=-");
  290. setVar("time", div(sub(endtime, starttime), 1000));
  291. player.speak(p, "§9HungerGames", "§eZeit§8: §r", math.round(div(time, 60)), " Minuten ", math.round(math.mod(time, 60)), " Sekunden");
  292. player.speak(p, "§9HungerGames", "§eDeine Kills§8: §r", getVar(concat(pname, "kills")));
  293. player.speak(p, "§9HungerGames", "§eDeine Kills gesamt§8: §r", ggV(pname, "hgkills"));
  294. player.speak(p, "§9HungerGames", "§eGespielte Spiele§8: §r", ggV(pname, "hgplayedgames"));
  295. player.speak(p, "§9HungerGames", "§eGewonnene Spiele§8: §r", gGV(pname, "hgwongames"));
  296. player.speak(p, "§9HungerGames", "§eSiegwahrscheinlichkeit§8: §r", math.roundComma(mul(div(ggV(pname, "hgwongames"), ggv(pname, "hgplayedgames")), 100), 2), "%");
  297. player.speak(p, "§9HungerGames", "§eDein Rang§8: §r", add(table.getIndexOf(hgrankstable, player.getUuid(p)), 1));
  298. }
  299. entity.removeAll("Item", middleloc, radius);
  300. entity.removeAll("Arrow", middleloc, radius);
  301. term();
  302. @giveup
  303. if(equal(phase, 0)) goto("leavelobby");
  304. entity.teleport(player, gamesworldloc);
  305. @leavegame
  306. if(list.contains(spectators, player-name)) command("gamemode SURVIVAL ", player-name);
  307. sb.reset(player);
  308. command("clear ", player-name);
  309. entity.setHealth(player, 20);
  310. player.setHunger(player, 20);
  311. player.setSaturation(player, 5);
  312. list.remove(all, player-name);
  313. list.remove(spectators, player-name);
  314. player.kick(player);
  315. goto("checkplayability");