123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- rankingtable = "rebuildranks";
- game_short = "rebuild";
- gamename = "§5Rebuild";
- specific_lobby_handling = true;
- no_core_reset = true;
- gosub("setstart");
- goto("simplelobby");
- @specificLobbyHandling
- if(event == "player_join") {
- entity.cleareffects(player);
- living.setHealth(player, 20);
- player.setHunger(player, 20);
- player.setSaturation(player, 5);
- player.clearInventory(player);
- display.reset(player);
- display.add(player, 1, gamename);
- display.add(player, 2, "§7Map:");
- display.add(player, 3, mapname);
- }
- return;
- @finalstart
- player_list = minigame.getPlayers(script_id);
- buildingarea = map.new();
- solved = map.new();
- check_list = list.new();
- if(list.getSize(player_list) == 1) {
- singleteam = true;
- for(i = 0; i < list.getSize(player_list); i++) {
- p = player.get(list.getIndex(player_list, i));
- msg.prefix(p, gamename, "Singleteam. Not ranked");
- }
- } else {
- singleteam = false;
- }
- for(i = 0; i < list.getSize(player_list); i++) {
- p_uuid = list.getIndex(player_list, i);
- p = player.get(p_uuid);
- map.add(solved, p_uuid, 0);
- msg.prefix(p, gamename, "The game has started.");
- list = list.new();
- map.add(buildingarea, p_uuid, list);
- edge = list.getIndex(bottom_edge, i);
- for(z = 0; z < picture_length; z++) {
- for(x = 0; x < picture_length; x++) {
- list.add(list, loc.mod(edge, x * -1, 0, z));
- }
- }
- }
- minigame.displayResetAll();
- minigame.displayAll(1, gamename);
- tobuild = list.getIndex(to_build_edges, 0);
- for(i = 0; i < list.getSize(player_list); i++) {
- p_uuid = list.getIndex(player_list, i);
- p = player.get(p_uuid);
- pname = player.getName(p);
- minigame.displayAll(i + 2, concat("§6", 0, " §c", pname));
- entity.teleport(p, list.getIndex(spawns, i));
- sound.spawnForPlayer(p, pling_sound, sound_category_ambient);
- player.setGamemode(p, "creative");
-
- title.clear(p);
- title.setTime(p, 0, 20, 0);
- //Vorlagen und Barriers setzen
- edge = list.getIndex(picture_edge, i); //Die erste Vorlage bekommt jeder
- for(y = 0; y < picture_length; y++) {
- for(x = 0; x > picture_length * -1; x--) {
- block.clone(loc.mod(tobuild, x, y, 0), loc.mod(edge, x, y, 0));
- block.set(loc.mod(edge, x, y, -1), "minecraft:barrier");
- }
- }
- }
- countdown = 5;
- @title
- for(i = 0; i < list.getSize(player_list); i++) {
- p = player.get(list.getIndex(player_list, i));
- title.send(p, concat("§c", text.number(countdown)));
- }
- if(countdown == 0) {
- sgoto(20, "setstarttime");
- } else {
- sgoto(20, "title");
- countdown--;
- }
- @checkstart
- wait();
- if(event == "block_click") {
- cancel = true;
- goto("checkstart");
- }
- if(event == "player_giveup" || event == "player_logout") {
- minigame.speakAll(gamename, concat("§6", player.getName(player), " §rhas left the game."));
- player.setGamemode(player, "survival");
- list = map.get(buildingarea, player.getUuid(player));
- for(i = 0; i < list.getSize(list); i++) {
- block.set(list.getIndex(list, i), "minecraft:air");
- }
- script = script.getFromId(script_id);
- minigame.kickplayer(script, player);
- if(list.getSize(player_list) < 2) {
- if(singleteam) {
- p = player;
- } else {
- p_uuid = list.getIndex(player_list, 0);
- p = player.get(p_uuid);
- }
- wincore(p);
- }
- }
- goto("checkstart");
- @setstarttime
- starttime = time.getMillis();
- for(i = 0; i < list.getSize(player_list); i++) {
- edge = list.getIndex(picture_edge, i);
- for(y = 0; y < picture_length; y++) {
- for(x = 0; x > picture_length * -1; x--) {
- block.set(loc.mod(edge, x, y, -1), "minecraft:air");
- }
- }
- }
- @checkgame
- wait();
- if(player.hasMinigameId(player, script_id)) {
- ignoreGoto(event);
- }
- goto("checkgame");
- @player_logout
- @player_giveup
- minigame.speakAll(gamename, concat("§6", player.getName(player), " §rhas left the game."));
- player.setGamemode(player, "survival");
- list = map.get(buildingarea, player.getUuid(player));
- for(i = 0; i < list.getSize(list); i++) {
- block.set(list.getIndex(list, i), "minecraft:air");
- }
- script = script.getFromId(script_id);
- minigame.kickplayer(script, player);
- if(list.getSize(player_list) < 2) {
- if(singleteam) {
- p = player;
- } else {
- p_uuid = list.getIndex(player_list, 0);
- p = player.get(p_uuid);
- }
- wincore(p);
- }
- goto("checkgame");
- @block_place
- @block_break
- player_uuid = player.getUuid(player);
- list = map.get(buildingarea, player_uuid);
- if(!list.contains(list, block_loc)) {
- cancel = true;
- goto("checkgame");
- }
- cancel = false;
- list.add(check_list, player_uuid);
- sgoto(2, "checkpicture");
- goto("checkgame");
- @checkpicture
- p_uuid = list.getIndex(check_list, 0);
- list.removeIndex(check_list, 0);
- p = player.get(p_uuid);
- temp_solved = map.get(solved, p_uuid);
- temploc = list.getIndex(bottom_check_edges, temp_solved);
- list = map.get(buildingarea, p_uuid);
- picture = list.getIndex(list, 0);
- for(z = 0; z < picture_length; z++) {
- for(x = 0; x > picture_length * -1; x--) {
- loc1 = loc.mod(temploc, x, 0, z);
- loc2 = loc.mod(picture, x, 0, z);
- if(block.getType(loc1) != block.getType(loc2)) {
- goto("checkgame");
- }
- }
- }
- temp_solved++;
- map.add(solved, p_uuid, temp_solved);
- player.clearInventory(p);
- for(i = 0; i < list.getSize(player_list); i++) {
- uuid = list.getIndex(player_list, i);
- minigame.displayAll(i + 2, concat("§6", text.number(map.get(solved, uuid)), "§c ", player.getName(uuid)));
- }
- if(temp_solved >= solve_to_win) {
- wincore(p);
- }
- list = map.get(buildingarea, p_uuid);
- for(i = 0; i < list.getSize(list); i++) {
- block.set(list.getIndex(list, i), "minecraft:air");
- }
- tobuild = list.getIndex(to_build_edges, temp_solved);
- edge = list.getIndex(picture_edge, list.getIndexOf(player_list, p_uuid));
- for(y = 0; y < picture_length; y++) {
- for(x = 0; x > picture_length * -1; x--) {
- block.clone(loc.mod(tobuild, x, y, 0), loc.mod(edge, x, y, 0));
- }
- }
- goto("checkgame");
- function wincore(winner) {
- winner_name = player.getName(winner);
- if(!$singleteam) {
- minigame.speakAll($gamename, concat("§b", winner_name, "§r has won!"));
- }
-
- for(h = 0; h < list.getSize($player_list); h++) {
- p_uuid = list.getIndex($player_list, h);
- list = map.get($buildingarea, p_uuid);
- for(i = 0; i < list.getSize(list); i++) {
- block.set(list.getIndex(list, i), "minecraft:air");
- }
- }
- for(i = 0; i < 5; i++) {
- edge = list.getIndex($picture_edge, i);
- for(y = 0; y < $picture_length; y++) {
- for(x = 0; x > $picture_length * -1; x--) {
- block.set(loc.mod(edge, x, y, 0), "minecraft:air");
- }
- }
- }
- entity.removeAll("net.minecraft.entity.item.ItemEntity", $middleloc, $radius);
- for(i = 0; i < list.getSize($player_list); i++) {
- p_uuid = list.getIndex($player_list, i);
- p = player.get(p_uuid);
- p_id = player.getId(p);
- player.setGamemode(p, "survival");
-
- if(!$singleteam) {
- last_record = ranking.getPoints($rankingtable, p_id);
- playedgames = minigame.getPlayed(p_id, $game_short) + 1;
- minigame.setPlayed(p_id, $game_short, playedgames);
- record = last_record + map.get($solved, p_uuid);
- ranking.setPoints($rankingtable, p_id, record);
- rebuildwon = minigame.getWon(p, "rebuild");
- if(p == winner) {
- rebuildwon++;
- minigame.setWon(p, "rebuild", rebuildwon);
- }
- msg(p, "");
- }
- minigame.statsHeader(p, $gamename, "§e");
- if($starttime != null) {
- endtime = time.getMillis();
- time = (endtime - $starttime) / 1000;
- minigame.statsLine(p, "§e", "Time", concat(text.number(math.round(time / 60)), " min ", text.number(math.round(time % 60)), " s"));
- }
- if(!$singleteam) {
- minigame.statsLine(p, "§e", "Solved Fields", text.number(record));
- minigame.statsLine(p, "§e", "Won games", text.number(rebuildwon));
- minigame.statsLine(p, "§e", "Played games", text.number(playedgames));
- if(playedgames != 0) {
- minigame.statsLine(p, "§e", "Win ratio", concat(text.number(math.roundComma((rebuildwon / playedgames) * 100, 2)), "%"));
- }
- }
- }
- script = script.getFromId($script_id);
- minigame.kickAllPlayers(script);
- minigame.term(script, $gamesignloc);
- term();
- }
|