123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458 |
- /*
- TODO und Ideen
- *) //edit
- *) sword wird nicht gegeben
- *) stats und rangliste einbauen
- *) removeitem bei resetflag (damals Bug)
- *) multiple teams
- *) ein gegneriches team wird ausgelöscht, wenn die eigene flagge UND die flagge des gegners in die eigene base gebracht wurde
- */
- rankingtable = "ctfranks";
- registerRanking(rankingtable);
- colorcodes = map.new();
- map.add(colorcodes, 0, "§9");
- map.add(colorcodes, 1, "§c");
- map.add(colorcodes, 2, "§e");
- map.add(colorcodes, 3, "§2");
- map.add(colorcodes, 4, "§6");
- map.add(colorcodes, 5, "§5");
- map.add(colorcodes, 6, "§d");
- map.add(colorcodes, 7, "§0");
- teamcolortext = map.new();
- map.add(teamcolortext, 0, "§9blue");
- map.add(teamcolortext, 1, "§cred");
- map.add(teamcolortext, 2, "§eyellow");
- map.add(teamcolortext, 3, "§2green");
- map.add(teamcolortext, 4, "§6orange");
- map.add(teamcolortext, 5, "§5magenta");
- map.add(teamcolortext, 6, "§dpink");
- map.add(teamcolortext, 7, "§0black");
- teamcolortext2 = map.new();
- map.add(teamcolortext2, 0, "§9Blue");
- map.add(teamcolortext2, 1, "§cRed");
- map.add(teamcolortext2, 2, "§eYellow");
- map.add(teamcolortext2, 3, "§2Green");
- map.add(teamcolortext2, 4, "§6Orange");
- map.add(teamcolortext2, 5, "§5Magenta");
- map.add(teamcolortext2, 6, "§dPink");
- map.add(teamcolortext2, 7, "§0Black");
- banners = map.new(); //Liste der Banner
- map.add(banners, 0, "minecraft:blue_banner");
- map.add(banners, 1, "minecraft:red_banner");
- map.add(banners, 2, "minecraft:yellow_banner");
- map.add(banners, 3, "minecraft:green_banner");
- map.add(banners, 4, "minecraft:orange_banner");
- map.add(banners, 5, "minecraft:purple_banner");
- map.add(banners, 6, "minecraft:pink_banner");
- map.add(banners, 7, "minecraft:black_banner");
- clothescode = map.new(); //Liste der Datenwerte für gefärbte Kleidung
- map.add(clothescode, 0, 5592575);
- map.add(clothescode, 1, 16733525);
- map.add(clothescode, 2, 16777045);
- map.add(clothescode, 3, 5635925);
- map.add(clothescode, 4, 16755200);
- map.add(clothescode, 5, 43690);
- map.add(clothescode, 6, 5592405);
- map.add(clothescode, 7, 0);
- gosub("setstart");
- air_item_type = "minecraft:air";
- air_item = read.item(air_item_type);
- minplayers = teamsize + 1;
- maxplayers = teamsize * numberofteams;
- compassitem = map.new(); //Map der Kompasse mit Namen
- teamlists = map.new(); //Map mit Spielerlisten für jedes Team
- for(team = 0; team < numberofteams; team++) {
- map.add(teamlists, team, list.new());
- map.add(compassitem, team, read.item("minecaft:compass", 1, concat(map.get(teamcolortext2, team), "e Flagge")));
- }
- all = list.new(); //Alle Spieler in der Quest
- waiters = list.new(); //Alle Spieler ohne ausgewähltem Team
- players = map.new(); //Alle Spieler mit ausgewähltem Team. Key: player_name / Value: Team
- compassmap = map.new(); //Auf welche Flagge zeigt der Kompass eines Spielers
- gamename = "§3CTF";
- player = script.getLeader();
- player_name = player.getName(player);
- gosub("lobbycore");
- goto("simplelobby");
- @lobby
- list.add(waiters, player_name);
- resetplayer(player);
- display.add(player, 0, gamename);
- display.add(player, 1, concat("§7Map: §b", mapname));
- display.add("all", 2, concat("§7Spieler: §r", text.number(list.getSize(all)), "/", text.number(maxplayers)));
- display.add(player, 3, concat("§7", text.number(numberofteams), " Teams"));
- if(ggv(player, "ctfwongames") == null) {
- sgv(player, "ctfwongames", 0);
- }
- if(ggv(player, "ctfstolenflags") == null) {
- sgv(player, "ctfstolenflags", 0);
- }
- return;
- @leavelobby
- list.remove(waiters, player_name);
- list.remove(getVar(map.get(players, player_name)), player_name);
- map.remove(players, player_name);
- return;
- @finalstart
- minigame.speakAll(gamename, "§rDas Spiel läuft.");
- size = list.getSize(all);
- block.setSign(gamesignloc, 2, concat(text.number(size), "/", text.number(maxplayers)));
- block.setSign(gamesignloc, 3, "§6Läuft");
- flagat = map.new(); //Wo befindet sich eine Flagge. Base/Gegnerische Base/Spieler/frei herumliegend
- flagatloc = map.new(); //Genaue Koordinaten, wo sich eine Flagge befindet
- for(team = 0; team < numberofteams; team++) {
- map.add(flagat, team, concat(map.get(colorcodes, team), "Base"));
- map.add(flagatloc, team, map.get(flaglocs, team));
- }
- //Spieler ohne Team einem Team zuweisen
- while(list.getSize(waiters) != 0) {
- team = getTeamWithLowestPeople();
- teamlist = map.get(teamlists, team);
- p_name = list.getIndex(waiters, 0);
- map.add(players, p_name, team);
- list.add(teamlist, p_name);
- list.remove(waiters, p_name);
- }
- flagcarrier = map.new();
- for(i = 0; i < size; i++) {
- p = list.getIndex(all, i);
- p_name = player.getName(p);
- team = map.get(players, p_name);
- entity.teleport(p, map.get(spawnlocs, team));
- map.add(compassmap, p_name, team);
- equipPlayer(p, team);
- map.add(flagcarrier, p_name, null);
- if(player.isSurvival(p)) {
- if(player.isAdventure(p)) {
- player.setGamemode(p, "survival");
- }
- } else {
- player.setGamemode(p, "survival");
- }
- if(player.hasFly(p)) {
- player.setFly(p, false);
- }
- }
- display.reset("all");
- display.add("all", 0, gamename);
- for(team = 0; team < numberofteams; team++) {
- templist = getVar(concat("flaglocs", team));
- for(h = 0; h < list.getSize(templist); h++) {
- tempflagloc = list.getIndex(templist, h);
- block.set(tempflagloc, air_item_type);
- event.addLoc(tempflagloc);
- }
- tempflagloc = list.getIndex(templist, 0);
- block.set2(tempflagloc, "standing_banner", map.get(flagdirection, tempflagloc), concat("{Base:", map.get(flagcolors, tempflagloc), "}"));
- display.add("all", i + 1, concat(map.get(teamcolortext2, team), "e Flagge: ", map.get(flagat, team)));
- }
- event.load("player_death");
- event.load("player_respawn");
- event.load("player_move");
- event.load("player_toss");
- event.load("player_pickup");
- event.load("item_air_click");
- event.load("player_giveup");
- event.load("player_logout");
- //sgoto(40, "loop");
- @checkgame
- wait();
- ignoreGoto(event);
- goto("wait");
- @item_air_click
- if(item.getType(living.getEquip(player, "hand")) == "COMPASS") {
- tempteamstring = map.get(compassmap, player_name);
- newtempteamstring = list.getIndex(allteams, list.getIndexOf(allteams, tempteamstring) + 1);
- tempcompass = map.get(compassitem, newtempteamstring);
- player.removeItem(player, item);
- player.giveItem(player, tempcompass);
- map.add(compassmap, player_name, newtempteamstring);
- player.setCompass(player, map.get(flagatloc, newtempteamstring));
- }
- goto("checkgame");
- @player_hurt
- if(player_involved) {
- if(map.get(players, player_name) == map.get(players, sec_player_name)) {
- cancel = true;
- }
- }
- goto("checkgame");
- @player_death
- player.respawn(player);
- tempteamstring = map.get(players, player_name);
- if(map.get(flagcarrier, player_name) == null) {
- goto("checkgame");
- }
- tempteamstring = map.get(flagcarrier, player_name);
- map.add(flagcarrier, player_name, null);
- player_loc = entity.getLocation(player);
- item.drop(player_loc, map.get(itembanner, tempteamstring));
- minigame.speakAll(gamename, concat("§rDie ", map.get(teamcolortext, tempteamstring), " §rFlagge wurde gedroppt."));
- map.add(flagat, tempteamstring, "§rGedroppt");
- map.add(flagatloc, tempteamstring, player_loc);
- display.add("all", list.getIndexOf(allteams, tempteamstring) + 1, concat(map.get(teamcolortext2, tempteamstring), " Flagge: ", map.get(flagat, tempteamstring)));
- setCompassNew(tempteamstring);
- goto("checkgame");
- @player_respawn
- tempteamstring = map.get(players, player_name);
- respawn_loc = map.get(spawnlocs, tempteamstring);
- command("clear ", player_name);
- equipPlayer(player, tempteamstring);
- goto("checkgame");
- @player_toss
- cancel = true;
- player.giveItem(player, item);
- goto("checkgame");
- @player_pickup
- if(item.getType(item) == "minecraft:banner") {
- tempteamstring = map.get(flagdata, item.getData(item));
- entity.remove(entity);
- goto("pickupflag");
- }
- goto("checkgame");
- @player_move
- moveloc = getMoveLocation(entity.getLocation(player));
- event.addLoc(moveloc);
- moveplayer = player_name;
- if(moveloc == oldmoveloc && moveplayer == oldmoveplayer) {
- goto("checkgame");
- }
- oldmoveloc = moveloc;
- oldmoveplayer = moveplayer;
- tempstack = block.toStack(moveloc);
- //Wenn ein Banner vorhanden ist
- if(item.getType(tempstack) == "minecraft:banner") {
- //Überprüfung, ob das Feld ein Ablagefeld des eigenen Teams ist
- tempteamstring = map.get(players, player_name);
- if(list.contains(getVar(concat("flaglocs", tempteamstring)), moveloc)) {
- goto("checkgame");
- }
- tempteamstring = map.get(flagdata, item.getData(tempstack));
- block.set(moveloc, air_item_type);
- goto("pickupflag");
- }
- //Wenn kein Banner vorhanden ist
- if(item.getType(tempstack) == "minecraft:air") {
- //Überprüfung, ob der Spieler ein Banner trägt
- if(map.get(flagcarrier, player_name) == null) {
- goto("checkgame");
- }
- //Überprüfung, ob das Feld ein Ablagefeld des eigenen Teams ist
- tempteamstring = map.get(players, player_name);
- if(!list.contains(getVar(concat("flaglocs", tempteamstring)), moveloc)) {
- goto("checkgame");
- }
- tempteamstring2 = map.get(flagcarrier, player_name);
- minigame.speakAll(gamename, concat("§rDie ", map.get(teamcolortext, tempteamstring2), " Flagge §rwurde von ", map.get(colorcodes, tempteamstring), "Team ", map.get(teamcolortext2, tempteamstring), " §rerobert"));
- block.set2(moveloc, "standing_banner", map.get(flagdirection, moveloc), concat("{Base:", map.get(flagcolors, moveloc), "}"));
- living.setEquip(player, "head", air_item);
- map.add(flagcarrier, player_name, null);
- map.add(flagat, tempteamstring2, concat(map.get(colorcodes, tempteamstring), "Base"));
- map.add(flagatloc, tempteamstring2, moveloc);
- display.add("all", list.getIndexOf(allteams, tempteamstring2) + 1, concat(map.get(teamcolortext2, tempteamstring2), "e Flagge: ", map.get(flagat, tempteamstring)));
- setCompassNew(tempteamstring2);
- //edit: wincheck
- }
- goto("checkgame");
- @block_break
- @block_place
- cancel = true;
- goto("checkgame");
- //Aktualisiert alle Kompasse, die auf dieses Team eingestellt sind
- function setCompassNew(tempteamstring) {
- for(i = 0; i < list.getSize($all); i++) {
- p = list.getIndex($all, i);
- p_name = player.getName(p);
- if(map.get($compassmap, p_name) == tempteamstring) {
- player.setCompass(p, map.get($flagatloc, tempteamstring));
- }
- }
- return;
- }
- function equipPlayer(player, tempteamstring) {
- clothescolor = map.get($clothescode, map.get(players, player_name));
- living.setEquip(player, "chest", read.item(concat("{id:\"minecraft:leather_chestplate\",Count:1b,tag:{display:{color:", clothescolor, "}}}")));
- player.giveItem(player, $sword);
- player.giveItem(player, $bow);
- player.giveItem(player, $food);
- player.giveItem(player, $gapple);
- player.giveItem(player, map.get($compassitem, tempteamstring));
- player.giveItem(player, $arrows);
- player.setCompass(player, map.get($flagatloc, map.get($compassmap, player.getName(player))));
- return;
- }
- //edit: Code unten alt
- /*@loop
- if(list.contains(all, bluecarrier)) {
- setVar("blueflagatloc", entity.getLocation(read.player(bluecarrier)));
- sgoto(1, "setbluecompassnew");
- }
- if(list.contains(all, redcarrier)) {
- setVar("redflagatloc", entity.getLocation(read.player(redcarrier)));
- sgoto(1, "setredcompassnew");
- }
- setVar("i", 0);
- @equip
- setVar("pname", list.getIndex(all, i));
- setVar("p", read.player(pname));
- if(list.contains(redteam, pname)) goto("equipred");
- living.setEquip(p, "head", read.item("{id:'minecraft:leather_helmet',Count:1b,tag:{display:{color:3361970}},Damage:0s}"));
- living.setEquip(p, "chest", read.item("{id:'minecraft:leather_chestplate',Count:1b,tag:{display:{color:3361970}},Damage:0s}"));
- living.setEquip(p, "legs", read.item("{id:'minecraft:leather_leggings',Count:1b,tag:{display:{color:3361970}},Damage:0s}"));
- living.setEquip(p, "feet", read.item("{id:'minecraft:leather_boots',Count:1b,tag:{display:{color:3361970}},Damage:0s}"));
- player.action(p, "§9Team Blau");
- if(less(inc("i"), list.getSize(all))) goto("equip");
- sgoto(40, "loop");
- goto("checkgame");
- @equipred
- living.setEquip(p, "head", read.item("{id:'minecraft:leather_helmet',Count:1b,tag:{display:{color:10040115}},Damage:0s}"));
- living.setEquip(p, "chest", read.item("{id:'minecraft:leather_chestplate',Count:1b,tag:{display:{color:10040115}},Damage:0s}"));
- living.setEquip(p, "legs", read.item("{id:'minecraft:leather_leggings',Count:1b,tag:{display:{color:10040115}},Damage:0s}"));
- living.setEquip(p, "feet", read.item("{id:'minecraft:leather_boots',Count:1b,tag:{display:{color:10040115}},Damage:0s}"));
- player.action(p, "§cTeam Rot");
- if(less(inc("i"), list.getSize(all))) goto("equip");
- sgoto(40, "loop");
- goto("checkgame");
- @blueflagloc
- if(and(list.contains(blueteam, player_name), equal(redcarrier, player_name))) goto("bluewin");
- if(and(list.contains(redteam, player_name), equal(blueflagat, "§rBase"))) goto("getblueflag");
- if(and(list.contains(blueteam, player_name), notequal(blueflagat, "§rBase"), equal(bluecarrier, player_name))) goto("resetblueflag");
- goto("checkgame");
- @resetblueflag
- player.removeItem(player, blueitembanner);
- block.clone(bluecopyflagloc, blueflagloc);
- event.addLoc(blueflagloc);
- setVar("blueflagat", "§rBase");
- setVar("blueflagatloc", blueflagloc);
- sb.add("all", 97, concat("§9Blaue Flagge: ", blueflagat));
- minigame.speakAll("§3CTF", "§rDie §9blaue §rFlagge ist wieder in ihrer Base.");
- goto("setbluecompassnew");
- @getblueflag
- setVar("color", "§c");
- block.set(blueflagloc, read.item("AIR"));
- player.giveItem(player, blueitembanner);
- event.addLoc(blueflagloc);
- goto("pickupblue");
- @redflagloc
- if(and(list.contains(redteam, player_name), equal(bluecarrier, player_name))) goto("redwin");
- if(and(list.contains(redteam, player_name), equal(redflagat, "§rBase"))) goto("addredflagloc");
- if(and(list.contains(blueteam, player_name), equal(redflagat, "§rBase"))) {
- block.set(entity.getLocation(player), air_item_type);
- //tempteamstring setzen
- living.setEquip(player, "head", map.get(itembanner, tempteamstring));
- goto("pickupred");
- }
- if(and(list.contains(redteam, player_name), notequal(redflagat, "§rBase"), equal(redcarrier, player_name))) goto("resetredflag");
- if(notequal(redflagat, "§rBase")) goto("addredflagloc");
- goto("checkgame");
- @addredflagloc
- event.addLoc(redflagloc);
- goto("checkgame");
- @resetflag
- living.setEquip(player, "head", air_item);
- block.clone(redcopyflagloc, redflagloc);
- setVar("redflagat", "§rBase");
- setVar("redflagatloc", redflagloc);
- sb.add("all", 96, concat("§cRote Flagge: ", redflagat));
- minigame.speakAll("§3CTF", "§rDie §crote §rFlagge ist wieder in der Base.");
- setCompassNew(tempteamstring);
- goto("checkgame");*/
- @pickupflag
- if(map.get(flagcarrier, player_name) != null) {
- msg.prefix(player, gamename, "§rDu trägst bereits eine Flagge.");
- block.set2(moveloc, "standing_banner", map.get(flagdirection, moveloc), concat("{Base:", map.get(flagcolors, moveloc), "}"));
- goto("checkgame");
- }
- tempteamstring2 = map.get(players, player_name);
- color = map.get(colorcodes, tempteamstring2);
- minigame.speakAll(gamename, concat(color, player_name, "§r trägt die ", map.get(teamcolortext, tempteamstring), " §rFlagge"));
- living.setEquip(player, "head", map.get(itembanner, tempteamstring));
- map.add(flagcarrier, player_name, tempteamstring);
- map.add(flagat, tempteamstring, concat(color, player_name));
- map.add(flagatloc, tempteamstring, entity.getLocation(player));
- display.add("all", list.getIndexOf(allteams, tempteamstring) + 1, concat(map.get(teamcolortext2, tempteamstring), "e Flagge: ", map.get(flagat, tempteamstring)));
- setCompassNew(tempteamstring);
- goto("checkgame");
- @checkplayability
- if(equal(list.getSize(blueteam), 0)) goto("redwin");
- if(equal(list.getSize(redteam), 0)) goto("bluewin");
- goto("checkgame");
- @bluewin
- setVar("colortext", "§9blaue");
- goto("wincore");
- @redwin
- setVar("colortext", "§crote");
- goto("wincore");
- @wincore
- minigame.speakAll("§3CTF", concat("§rDas ", colortext, "§r Team hat gewonnen!"));
- for(i = 0; i < list.getSize(all); i++) {
- p = list.getIndex(all, i);
- p_name = player.getName(p);
- resetplayer(p);
- tptogameslobby(p);
- }
- entity.removeAll("net.minecraft.entity.item.ItemEntity", middleloc, radius);
- block.setSign(gamesignloc, 2, concat("0/", text.number(maxplayers)));
- block.setSign(gamesignloc, 3, "§2Bereit");
- term();
- @player_logout
- @player_giveup
- kickplayer(player);
- list.remove(waiters, player_name);
- goto("checkplayability");
- function getMoveLocation(location) {
- world = loc.getCoord(location, "w");
- x = math.roundDown(loc.getX(location));
- y = math.roundDown(loc.getY(location));
- z = math.roundDown(loc.getZ(location));
- moveloc = loc.new(world, x, y, z);
- return moveloc;
- }
|