sinkships.txt 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. event.load("player_join");
  2. event.load("player_leave");
  3. event.load("player_giveup");
  4. event.load("player_hurt");
  5. event.load("block_click");
  6. list.new("all");
  7. gamesworldloc = read.location(ggv("SERVER", "gamesspawn"));
  8. no_quest_msg = true;
  9. started = false;
  10. airblock = read.item("AIR");
  11. gamename = "§1SinkShips";
  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 Variieren 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. if(ggv(player, "sinkshipplayed") == null) {
  38. sgv(player, "sinkshipplayed", 0);
  39. }
  40. if(ggv(player, "sinkshipwon") == null) {
  41. sgv(player, "sinkshipwon", 0);
  42. }
  43. player.speak(player_name, gamename, "§rDu befindest dich in der ", gamename, " §rLobby.");
  44. if(!started) {
  45. if(list.getSize(all) >= playersneeded) {
  46. goto("startgame");
  47. }
  48. @waiting
  49. started = false;
  50. counterindex = 0;
  51. waitfor = playersneeded - list.getSize(all);
  52. player.speak("all", gamename, "§rEs wird auf ", concat("§6", waitfor), " §rSpieler gewartet.");
  53. }
  54. @checklobby
  55. wait();
  56. if(event == "player_join") {
  57. goto("lobby");
  58. }
  59. if(event == "player_leave" || event == "player_giveup") {
  60. goto("leavelobby");
  61. }
  62. if(event == "block_click" || event == "player_hurt") {
  63. cancel = true;
  64. goto("checklobby");
  65. }
  66. goto("checklobby");
  67. @leavelobby
  68. list.remove(all, player_name);
  69. block.setSign(gamesignloc, 2, concat(list.getSize(all), "/", maxplayers));
  70. if(list.getSize(all) < playersneeded) {
  71. block.setSign(gamesignloc, 3, "§2Wartet");
  72. }
  73. entity.teleport(player, gamesworldloc);
  74. entity.setHealth(player, 20);
  75. player.setHunger(player, 20);
  76. player.setSaturation(player, 5);
  77. player.kick(player);
  78. goto("checklobby");
  79. @startgame
  80. if(list.getSize(all) < playersneeded) {
  81. goto("waiting");
  82. }
  83. started = true;
  84. block.setSign(gamesignloc, 3, "§bStartet");
  85. noticetime = list.getIndex(starttimes, counterindex);
  86. if(noticetime == 5) {
  87. for(i = 0; i <= list.getSize(all) - 1; i++) {
  88. title.setSub(read.player(list.getIndex(all, i)), mapname);
  89. title.send(read.player(list.getIndex(all, i)), gamename);
  90. }
  91. }
  92. if(noticetime == 0) {
  93. goto("finalstart");
  94. }
  95. noticetime2 = list.getIndex(starttimes, inc("counterindex"));
  96. if(noticetime == 1) {
  97. player.speak("all", gamename, concat("§rDas Spiel startet in §6", noticetime, " §rSekunde."));
  98. } else {
  99. player.speak("all", gamename, concat("§rDas Spiel startet in §6", noticetime, " §rSekunden."));
  100. }
  101. stime = (noticetime - noticetime2) * 20;
  102. sgoto(stime, "startgame");
  103. for(i = 0; i <= list.getSize(all) - 1; i++) {
  104. p = read.player(list.getIndex(all, i));
  105. player.playSound(p, "block.note.bass");
  106. }
  107. goto("checklobby");
  108. @finalstart
  109. no_join = true;
  110. event.load("custom_command");
  111. command.add("setship");
  112. command.add("delship");
  113. player.speak("all", gamename, "§rSetzt die Schiffe!");
  114. block.setSign(gamesignloc, 2, concat(list.getSize(all), "/", maxplayers));
  115. block.setSign(gamesignloc, 3, "§6Läuft");
  116. map.new("shiptoset"); //Speichert die Länge des zu setzenden Schiffs
  117. map.new("gameplayerid");
  118. for(i = 0; i <= list.getSize(all) - 1; i++) {
  119. pname = list.getIndex(all, i);
  120. p = read.player(pname);
  121. map.add(gameplayerid, pname, i);
  122. entity.teleport(p, list.getIndex(startlocs, i));
  123. if(player.isSurvival(p)) {
  124. if(player.isAdventure(p)) {
  125. command("gamemode survival ", pname);
  126. }
  127. } else {
  128. command("gamemode survival ", pname);
  129. }
  130. if(player.hasFly(p)) {
  131. command("fly ", pname, " off");
  132. }
  133. }
  134. @checkpregame
  135. wait();
  136. if(event == "player_leave" || event == "player_giveup") {
  137. goto("leavegame");
  138. }
  139. if(event == "custom_command") {
  140. if(command == "setship") {
  141. pos1 = getVar(concat(player_name, "_pos1"));
  142. pos2 = getVar(concat(player_name, "_pos2"));
  143. if(pos1 == null || pos2 == null) {
  144. player.speak(player, gamename, "§rMarkiere zuerst Pos1 und Pos2");
  145. goto("checkpregame");
  146. }
  147. xpos1 = loc.getX(pos1);
  148. zpos1 = loc.getZ(pos1);
  149. xpos2 = loc.getX(pos2);
  150. zpos2 = loc.getZ(pos2);
  151. direction = "x"; //In welche Richtung das Schiff liegt
  152. if(xpos1 != xpos2) {
  153. direction = "z";
  154. if(zpos1 != zpos2) {
  155. removeVar("direction");
  156. player.speak(player, gamename, "§rPos1 und Pos2 liegen nicht auf einer Linie");
  157. goto("checkpregame");
  158. }
  159. }
  160. set.new("tempset");
  161. if(direction = "x") {
  162. if(zpos1 > zpos2) {
  163. for(i = 0; i <= zpos1 - zpos2; i++) {
  164. set.add(tempset, loc.mod(pos2, 0, 0, i));
  165. }
  166. } else {
  167. for(i = 0; i <= zpos2 - zpos1; i++) {
  168. set.add(tempset, loc.mod(pos1, 0, 0, i));
  169. }
  170. }
  171. } else {
  172. if(xpos1 > xpos2) {
  173. for(i = 0; i <= xpos1 - xpos2; i++) {
  174. set.add(tempset, loc.mod(pos2, 0, 0, i));
  175. }
  176. } else {
  177. for(i = 0; i <= xpos2 - xpos1; i++) {
  178. set.add(tempset, loc.mod(pos1, 0, 0, i));
  179. }
  180. }
  181. }
  182. tempsetsize = set.size(tempset);
  183. if(tempsetsize != map.get(shiptoset, player_name)) {
  184. player.speak(player, gamename, "§rDer ausgewählte Bereich entspricht nicht der Länge des zu setzenden Schiffs");
  185. goto("checkpregame");
  186. }
  187. //Überschneidung mit anderen Schiffen?
  188. i = map.get(gameplayerid, player_name);
  189. for(g = 0; g <= tempsetsize - 1; g++) {
  190. for(h = 1; h <= shipsperplayer; h++) {
  191. if(set.contains(getVar(concat(i, "ship", h)), checkloc)) {
  192. player.speak(player, gamename, "§rDer ausgewählte Bereich überschneidet sich mit anderen Schiffen");
  193. goto("checkpregame");
  194. }
  195. }
  196. }
  197. }
  198. //Schiff setzen
  199. goto("checkpregame");
  200. }
  201. if(event == "player_hurt") {
  202. cancel = true;
  203. goto("checkpregame");
  204. }
  205. if(event == "block_click") {
  206. cancel = true;
  207. if(block_type == "minecraft:wall_sign") {
  208. signline0 = block.getSign(block_loc, 0);
  209. if(set.contains(signnames, signline0)) {
  210. map.add(shiptoset, player_name, block.getSign(block_loc, 2));
  211. player.speak(player, gamename, concat("§r", signline0, " ausgewählt"));
  212. }
  213. goto("checkpregame");
  214. }
  215. if(block_type == seablock) {
  216. if(action == "left") {
  217. setVar(concat(player_name, "_pos1"), block_loc);
  218. player.speak(player, gamename, concat("§dPos1: §r", loc.getX(block_loc), "/", loc.getZ(block_loc)));
  219. goto("checkpregame");
  220. }
  221. if(action == "right") {
  222. setVar(concat(player_name, "_pos2"), block_loc);
  223. player.speak(player, gamename, concat("§dPos2: §r", loc.getX(block_loc), "/", loc.getZ(block_loc)));
  224. goto("checkpregame");
  225. }
  226. }
  227. goto("checkpregame");
  228. }
  229. goto("checkpregame");