123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- event.load("player_join");
- event.load("player_leave");
- event.load("player_giveup");
- event.load("player_hurt");
- event.load("block_click");
- list.new("all");
- gamesworldloc = read.location(ggv("SERVER", "gamesspawn"));
- no_quest_msg = true;
- started = false;
- airblock = read.item("AIR");
- gamename = "§1SinkShips";
- counterindex = 0; //Laufvariable zum Mitzählen, welche Zeit des Startcountdowns als nächsten an der Reihe ist
- list.new("starttimes"); //Liste zum schnellen Variieren 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);
- if(ggv(player, "sinkshipplayed") == null) {
- sgv(player, "sinkshipplayed", 0);
- }
- if(ggv(player, "sinkshipwon") == null) {
- sgv(player, "sinkshipwon", 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);
- 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;
- event.load("custom_command");
- command.add("setship");
- command.add("delship");
- player.speak("all", gamename, "§rSetzt die Schiffe!");
- block.setSign(gamesignloc, 2, concat(list.getSize(all), "/", maxplayers));
- block.setSign(gamesignloc, 3, "§6Läuft");
- map.new("shiptoset"); //Speichert die Länge des zu setzenden Schiffs
- map.new("gameplayerid");
- for(i = 0; i <= list.getSize(all) - 1; i++) {
- pname = list.getIndex(all, i);
- p = read.player(pname);
- map.add(gameplayerid, pname, i);
- 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");
- }
- }
- @checkpregame
- wait();
- if(event == "player_leave" || event == "player_giveup") {
- goto("leavegame");
- }
- if(event == "custom_command") {
- if(command == "setship") {
- pos1 = getVar(concat(player_name, "_pos1"));
- pos2 = getVar(concat(player_name, "_pos2"));
- if(pos1 == null || pos2 == null) {
- player.speak(player, gamename, "§rMarkiere zuerst Pos1 und Pos2");
- goto("checkpregame");
- }
- xpos1 = loc.getX(pos1);
- zpos1 = loc.getZ(pos1);
- xpos2 = loc.getX(pos2);
- zpos2 = loc.getZ(pos2);
- direction = "x"; //In welche Richtung das Schiff liegt
- if(xpos1 != xpos2) {
- direction = "z";
- if(zpos1 != zpos2) {
- removeVar("direction");
- player.speak(player, gamename, "§rPos1 und Pos2 liegen nicht auf einer Linie");
- goto("checkpregame");
- }
- }
- set.new("tempset");
- if(direction = "x") {
- if(zpos1 > zpos2) {
- for(i = 0; i <= zpos1 - zpos2; i++) {
- set.add(tempset, loc.mod(pos2, 0, 0, i));
- }
- } else {
- for(i = 0; i <= zpos2 - zpos1; i++) {
- set.add(tempset, loc.mod(pos1, 0, 0, i));
- }
- }
- } else {
- if(xpos1 > xpos2) {
- for(i = 0; i <= xpos1 - xpos2; i++) {
- set.add(tempset, loc.mod(pos2, 0, 0, i));
- }
- } else {
- for(i = 0; i <= xpos2 - xpos1; i++) {
- set.add(tempset, loc.mod(pos1, 0, 0, i));
- }
- }
- }
- tempsetsize = set.size(tempset);
- if(tempsetsize != map.get(shiptoset, player_name)) {
- player.speak(player, gamename, "§rDer ausgewählte Bereich entspricht nicht der Länge des zu setzenden Schiffs");
- goto("checkpregame");
- }
- //Überschneidung mit anderen Schiffen?
- i = map.get(gameplayerid, player_name);
- for(g = 0; g <= tempsetsize - 1; g++) {
- for(h = 1; h <= shipsperplayer; h++) {
- if(set.contains(getVar(concat(i, "ship", h)), checkloc)) {
- player.speak(player, gamename, "§rDer ausgewählte Bereich überschneidet sich mit anderen Schiffen");
- goto("checkpregame");
- }
- }
- }
- }
- //Schiff setzen
- goto("checkpregame");
- }
- if(event == "player_hurt") {
- cancel = true;
- goto("checkpregame");
- }
- if(event == "block_click") {
- cancel = true;
- if(block_type == "minecraft:wall_sign") {
- signline0 = block.getSign(block_loc, 0);
- if(set.contains(signnames, signline0)) {
- map.add(shiptoset, player_name, block.getSign(block_loc, 2));
- player.speak(player, gamename, concat("§r", signline0, " ausgewählt"));
- }
- goto("checkpregame");
- }
- if(block_type == seablock) {
- if(action == "left") {
- setVar(concat(player_name, "_pos1"), block_loc);
- player.speak(player, gamename, concat("§dPos1: §r", loc.getX(block_loc), "/", loc.getZ(block_loc)));
- goto("checkpregame");
- }
- if(action == "right") {
- setVar(concat(player_name, "_pos2"), block_loc);
- player.speak(player, gamename, concat("§dPos2: §r", loc.getX(block_loc), "/", loc.getZ(block_loc)));
- goto("checkpregame");
- }
- }
- goto("checkpregame");
- }
- goto("checkpregame");
|