123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346 |
- event.load("player_hurt");
- event.load("block_click");
- event.load("player_leave");
- event.load("player_giveup");
- no_quest_msg = true;
- started = false;
- list.new("all");
- list.new("spectators");
- barrierblock = read.item("BARRIER");
- airblock = read.item("AIR");
- gamename = "§9HungerGames";
- counterindex = 0; //Laufvariable zum Mitzählen, welche Zeit des Startcountdowns als nächsten an der Reihe ist
- list.new("starttimes"); //Liste zum schnellen Varrieren des Startcountdowns
- list.add(starttimes, 20);
- list.add(starttimes, 15);
- list.add(starttimes, 10);
- list.add(starttimes, 5);
- list.add(starttimes, 4);
- list.add(starttimes, 3);
- list.add(starttimes, 2);
- list.add(starttimes, 1);
- list.add(starttimes, 0);
- @lobby
- if(list.getSize(all) >= maxplayers) {
- player.speak(player, gamename, "§rDiese Map ist bereits voll.");
- player.kick(player);
- goto("checklobby");
- }
- player.speak("all", gamename, concat("§6", player_name, " §rhat das Spiel betreten"));
- list.add(all, player_name);
- block.setSign(gamesignloc, 2, concat(list.getSize(all), "/", maxplayers));
- command("clear ", player_name);
- entity.setHealth(player, 20);
- player.setHunger(player, 20);
- player.setSaturation(player, 5);
- entity.teleport(player, lobbyloc);
- display.reset(player);
- display.add(player, 0, gamename);
- display.add(player, 1, "§7Map:");
- display.add(player, 2, concat("§b", mapname));
- display.add("all", 3, concat("§7Spieler: §r", concat(list.getSize(all), "/", gamesize)));
- display.add(player, 4, teams);
- setVar(concat(player_name, "hgkills"), 0);
- sgv(player_name, "hgplayedgames", add(ggv(player_name, "hgplayedgames"), 1));
- if(ggv(player, "hgplayedgames") == null) {
- sgv(player, "hgplayedgames", 0);
- }
- if(ggv(player, "hgwongames") == null) {
- sgv(player, "hgwongames", 0);
- }
- player.speak(player_name, gamename, "§rDu befindest dich in der ", gamename, " §rLobby.");
- if(!started) {
- if(list.getSize(all) >= playersneeded) {
- goto("startgame");
- }
- @waiting
- started = false;
- counterindex = 0;
- waitfor = playersneeded - list.getSize(all);
- player.speak("all", gamename, "§rEs wird auf ", concat("§6", waitfor), " §rSpieler gewartet.");
- }
- @checklobby
- wait();
- if(event == "player_join") {
- goto("lobby");
- }
- if(event == "player_leave" || event == "player_giveup") {
- goto("leavelobby");
- }
- if(event == "block_click" || event == "player_hurt") {
- cancel = true;
- goto("checklobby");
- }
- goto("checklobby");
- @leavelobby
- list.remove(all, player_name);
- block.setSign(gamesignloc, 2, concat(list.getSize(all), "/", maxplayers));
- if(list.getSize(all) < playersneeded) {
- block.setSign(gamesignloc, 3, "§2Wartet");
- }
- entity.teleport(player, gamesworldloc);
- display.reset(player);
- display.add("all", 3, concat("§7Spieler: §r", concat(list.getSize(all), "/", gamesize)));
- entity.setHealth(player, 20);
- player.setHunger(player, 20);
- player.setSaturation(player, 5);
- player.kick(player);
- goto("checklobby");
- @startgame
- if(list.getSize(all) < playersneeded) {
- goto("waiting");
- }
- started = true;
- block.setSign(gamesignloc, 3, "§bStartet");
- noticetime = list.getIndex(starttimes, counterindex);
- if(noticetime == 5) {
- for(i = 0; i <= list.getSize(all) - 1; i++) {
- title.setSub(read.player(list.getIndex(all, i)), mapname);
- title.send(read.player(list.getIndex(all, i)), gamename);
- }
- }
- if(noticetime == 0) {
- goto("finalstart");
- }
- noticetime2 = list.getIndex(starttimes, inc("counterindex"));
- if(noticetime == 1) {
- player.speak("all", gamename, concat("§rDas Spiel startet in §6", noticetime, " §rSekunde."));
- } else {
- player.speak("all", gamename, concat("§rDas Spiel startet in §6", noticetime, " §rSekunden."));
- }
- stime = (noticetime - noticetime2) * 20;
- sgoto(stime, "startgame");
- for(i = 0; i <= list.getSize(all) - 1; i++) {
- p = read.player(list.getIndex(all, i));
- player.playSound(p, "block.note.bass");
- }
- goto("checklobby");
- @finalstart
- no_join = true;
- player.speak("all", gamename, "§rDas Spiel läuft.");
- block.setSign(gamesignloc, 2, concat(list.getSize(all), "/", maxplayers));
- block.setSign(gamesignloc, 3, "§6Läuft");
- map.new("lifes");
- map.new("usedeffects");
- map.new("lastdamage");
- list.new("resetlist");
- for(i = 0; i <= list.getSize(all) - 1; i++) {
- pname = list.getIndex(all, i);
- p = read.player(pname);
- entity.teleport(p, list.getIndex(startlocs, i));
- if(player.isSurvival(p)) {
- if(player.isAdventure(p)) {
- command("gamemode survival ", pname);
- }
- } else {
- command("gamemode survival ", pname);
- }
- if(player.hasFly(p)) {
- command("fly ", pname, " off");
- }
- setVar(concat(pname, "knocked"), 0);
- player.giveItem(p, knockback1);
- map.add(lastdamage, pname, null);
- map.add(lifes, pname, 5);
- map.add(usedeffects, pname, 0);
- }
- display.reset("all");
- display.add("all", 0, "§9HungerGames");
- display.add("all", 1, teams);
- display.add("all", 2, "§eSpieler verbleibend: §b", list.getSize(all));
- for(i = 0; i <= list.getSize(spawns) - 1; i++) {
- block.set(loc.mod(list.getIndex(spawns, i), 1, 0, 0), barrierblock);
- block.set(loc.mod(list.getIndex(spawns, i), -1, 0, 0), barrierblock);
- block.set(loc.mod(list.getIndex(spawns, i), 0, 0, 1), barrierblock);
- block.set(loc.mod(list.getIndex(spawns, i), 0, 0, -1), barrierblock);
- block.set(loc.mod(list.getIndex(spawns, i), 0, 2, 0), barrierblock);
- }
- //Code unten alt
- @fillchests
- setVar("i", 0);
- @filllabel
- block.clone(list.getIndex(chests, math.random(0, sub(list.getSize(aimchests), 1))), list.getIndex(aimchests, i));
- if(less(inc("i"), list.getSize(chests))) goto("filllabel");
- setVar("i", -1);
- while(less(inc("i"), list.getSize(all))) {
- setVar("p", read.player(list.getIndex(all, i)));
- title.clear(p);
- title.setTime(p, 0, 20, 0);
- }
- @checkstart
- wait();
- if(event == "player_leave" || event == "player_giveup") {
- goto("leavegame");
- }
- if(event == "block_click" || event == "player_hurt") {
- cancel = true;
- goto("checkstart");
- }
- goto("checkstart");
- @finalstart
- setVar("i", -1);
- while(less(inc("i"), list.getSize(spawns))) {
- block.set(loc.mod(list.getIndex(spawns, i), 1, 0, 0), airblock);
- block.set(loc.mod(list.getIndex(spawns, i), -1, 0, 0), airblock);
- block.set(loc.mod(list.getIndex(spawns, i), 0, 0, 1), airblock);
- block.set(loc.mod(list.getIndex(spawns, i), 0, 0, -1), airblock);
- block.set(loc.mod(list.getIndex(spawns, i), 0, 2, 0), airblock);
- }
- setVar("i", -1);
- while(less(inc("i"), list.getSize(all))) {
- setVar("p", read.player(list.getIndex(all, i)));
- title.setTime(p, 20, 0, 20);
- title.send(p, "§cKeine Schutzzeit");
- }
- setVar("starttime", time.get());
- event.load("player-death");
- event.load("player-respawn");
- event.unload("block-click");
- @startloop
- sgoto(100, "loop");
- @checkgame
- wait();
- if(or(equal(event, "block-place"), equal(event, "block-break"))) {
- setVar("cancel", true);
- }
- if(and(equal(event, "player-death"), equal(player-killed, true), invert(list.contains(spectators, player-name)))) {
- goto("death");
- }
- //if(event, ==, player-respawn, then, sgoto, 1, respawn)
- if(equal(event, "player-leave")) {
- goto("leavegame");
- }
- goto("checkgame");
- @loop
- if(equal(list.getSize(spectators), 0)) goto("startloop");
- setVar("i", -1);
- while(less(inc("i"), list.getSize(spectators))) {
- setVar("p", read.player(list.getIndex(spectators, i)));
- if(greater(loc.distance(entity.getLocation(p), middleloc), radius)) {
- entity.teleport(p, middleloc);
- }
- }
- goto("startloop");
- @respawn
- command("gamemode 3 ", player-name);
- entity.teleport(player, middleloc);
- if(invert(list.contains(spectators, player-name))) list.add(spectators, player-name);
- goto("checkgame");
- @death
- command("clear ", player-name);
- if(notequal(sec-player-name, null)) goto("deathbyplayer");
- @singledeath
- player.speak("all", "§9HungerGames", "§8", player-name, "§e ist gestorben.");
- list.remove(all, player-name);
- player.respawn(player);
- sgoto(2, "checkplayability");
- sgoto(1, "respawn");
- goto("checkgame");
- @deathbyplayer
- if(equal(player-name, sec-player-name)) goto("singledeath");
- player.speak("all", "§9HungerGames", "§8", player-name, "§e ist durch §8", sec-player-name, "§e gestorben.");
- sgv(sec-player-name, "hgkills", add(ggv(sec-player-name, "hgkills"), 1));
- inc(concat(sec-player-name, "kills"));
- list.remove(all, player-name);
- setVar("sec-player-name", null);
- player.respawn(player);
- sgoto(2, "checkplayability");
- sgoto(1, "respawn");
- goto("checkgame");
- @checkplayability
- if(lessequal(list.getSize(all), 1)) {
- goto("win");
- } else() {
- player.speak("all", "§9HungerGames", "§eEs sind noch §b", list.getSize(all), " §eSpieler im Spiel.");
- sb.add("all", 1, "§eSpieler verbleibend: §b", list.getSize(all));
- }
- goto("checkgame");
- @win
- setVar("endtime", time.get());
- setVar("pname", list.getIndex(all, 0));
- setVar("p", read.player(pname));
- player.speak("all", "§9HungerGames", "§8", pname, "§e hat gewonnen.");
- sgv(pname, "hgwongames", add(ggv(pname, "hgwongames"), 1));
- gmap.add("hgranks", player.getUuid(p), ggv(pname, "hgwongames"));
- quest.playersToList(all);
- setVar("i", -1);
- while(less(inc("i"), list.getSize(spectators))) {
- setVar("pname", list.getIndex(spectators, i));
- list.remove(spectators, pname);
- list.add(all, pname);
- command("gamemode SURVIVAL ", pname);
- }
- removeVar("spectators");
- gmap.toTable("hgrankstable", "hgranks");
- table.setSortColumn(hgrankstable, 1);
- table.sort(hgrankstable);
- table.reverse(hgrankstable);
- table.setSortColumn(hgrankstable, 0);
- setVar("i", -1);
- while(less(inc("i"), list.getSize(all))) {
- setVar("pname", list.getIndex(all, i));
- setVar("p", read.player(pname));
- sb.reset(p);
- entity.teleport(p, gamesworldloc);
- entity.setHealth(p, 20);
- player.setHunger(p, 20);
- player.setSaturation(p, 5);
- command("clear ", pname);
- player.speak(p, "§9HungerGames", "§7-= §eStatistik dieses Spiels §7=-");
- setVar("time", div(sub(endtime, starttime), 1000));
- player.speak(p, "§9HungerGames", "§eZeit§8: §r", math.round(div(time, 60)), " Minuten ", math.round(math.mod(time, 60)), " Sekunden");
- player.speak(p, "§9HungerGames", "§eDeine Kills§8: §r", getVar(concat(pname, "kills")));
- player.speak(p, "§9HungerGames", "§eDeine Kills gesamt§8: §r", ggV(pname, "hgkills"));
- player.speak(p, "§9HungerGames", "§eGespielte Spiele§8: §r", ggV(pname, "hgplayedgames"));
- player.speak(p, "§9HungerGames", "§eGewonnene Spiele§8: §r", gGV(pname, "hgwongames"));
- player.speak(p, "§9HungerGames", "§eSiegwahrscheinlichkeit§8: §r", math.roundComma(mul(div(ggV(pname, "hgwongames"), ggv(pname, "hgplayedgames")), 100), 2), "%");
- player.speak(p, "§9HungerGames", "§eDein Rang§8: §r", add(table.getIndexOf(hgrankstable, player.getUuid(p)), 1));
- }
- entity.removeAll("Item", middleloc, radius);
- entity.removeAll("Arrow", middleloc, radius);
- term();
- @giveup
- if(equal(phase, 0)) goto("leavelobby");
- entity.teleport(player, gamesworldloc);
- @leavegame
- if(list.contains(spectators, player-name)) command("gamemode SURVIVAL ", player-name);
- sb.reset(player);
- command("clear ", player-name);
- entity.setHealth(player, 20);
- player.setHunger(player, 20);
- player.setSaturation(player, 5);
- list.remove(all, player-name);
- list.remove(spectators, player-name);
- player.kick(player);
- goto("checkplayability");
|