123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481 |
- rankingtable = "fncranks";
- game_short = "hs";
- cooldown_map = map.new();
- brokenblocks = map.new();
- placedblocks = list.new();
- points = map.new();
- times = map.new();
- seekerlist = list.new();
- escaperlist = list.new();
- winpoints = 30; //Punkte für Win
- gamename = "§9Hide and Seek";
- seeker_skills = list.new();
- hider_skills = list.new();
- addSeekerSkill("Speed", 20, "km:skill54", 5, 2, false, "speed");
- addSeekerSkill("JumpBoost", 12, "km:skill15", 3, 5, false, "jump_boost");
- addSeekerSkill("Haste", 25, "km:skill50", 7, 3, false, "haste");
- addSeekerSkill("Slowness", 25, "km:skill53", 3, 1, true, "slowness");
- addSeekerSkill("Glowing", 50, "km:skill3", 2, 1, true, "glowing");
- addHiderSkill("Invisibility", 45, "km:skill47", 10, 1, false, "invisibility");
- addHiderSkill("Haste", 25, "km:skill50", 7, 3, false, "haste");
- addHiderSkill("Slowness", 25, "km:skill53", 3, 1, true, "slowness");
- addHiderSkill("Blindness", 25, "km:skill55", 3, 1, true, "blindness");
- addHiderSkill("Nausea", 25, "km:skill36", 10, 10, true, "nausea");
- specific_lobby_handling = true;
- no_core_reset = true;
- gosub("setstart");
- spawnprotect = list.new();
- list.add(spawnprotect, middleloc);
- list.add(spawnprotect, loc.mod(middleloc, 0, 1, 0));
- list.add(spawnprotect, loc.mod(middleloc, -1, 0, 0));
- list.add(spawnprotect, loc.mod(middleloc, -1, 1, 0));
- list.add(spawnprotect, loc.mod(middleloc, 1, 0, 0));
- list.add(spawnprotect, loc.mod(middleloc, 1, 1, 0));
- list.add(spawnprotect, loc.mod(middleloc, 0, 0, 1));
- list.add(spawnprotect, loc.mod(middleloc, 0, 1, 1));
- list.add(spawnprotect, loc.mod(middleloc, 0, 0, -1));
- list.add(spawnprotect, loc.mod(middleloc, 0, 1, -1));
- list.add(spawnprotect, escaper_spawn_loc);
- list.add(spawnprotect, loc.mod(escaper_spawn_loc, 0, 1, 0));
- list.add(spawnprotect, loc.mod(escaper_spawn_loc, -1, 0, 0));
- list.add(spawnprotect, loc.mod(escaper_spawn_loc, -1, 1, 0));
- list.add(spawnprotect, loc.mod(escaper_spawn_loc, 1, 0, 0));
- list.add(spawnprotect, loc.mod(escaper_spawn_loc, 1, 1, 0));
- list.add(spawnprotect, loc.mod(escaper_spawn_loc, 0, 0, 1));
- list.add(spawnprotect, loc.mod(escaper_spawn_loc, 0, 1, 1));
- list.add(spawnprotect, loc.mod(escaper_spawn_loc, 0, 0, -1));
- list.add(spawnprotect, loc.mod(escaper_spawn_loc, 0, 1, -1));
- list.add(spawnprotect, seeker_spawn_loc);
- list.add(spawnprotect, loc.mod(seeker_spawn_loc, 0, 1, 0));
- list.add(spawnprotect, loc.mod(seeker_spawn_loc, -1, 0, 0));
- list.add(spawnprotect, loc.mod(seeker_spawn_loc, -1, 1, 0));
- list.add(spawnprotect, loc.mod(seeker_spawn_loc, 1, 0, 0));
- list.add(spawnprotect, loc.mod(seeker_spawn_loc, 1, 1, 0));
- list.add(spawnprotect, loc.mod(seeker_spawn_loc, 0, 0, 1));
- list.add(spawnprotect, loc.mod(seeker_spawn_loc, 0, 1, 1));
- list.add(spawnprotect, loc.mod(seeker_spawn_loc, 0, 0, -1));
- list.add(spawnprotect, loc.mod(seeker_spawn_loc, 0, 1, -1));
- escaper_spawn_loc = loc.mod(escaper_spawn_loc, 0.5, 0, 0.5);
- seeker_spawn_loc = loc.mod(seeker_spawn_loc, 0.5, 0, 0.5);
- 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);
- }
- return;
- @finalstart
- player_list = minigame.getPlayers(script_id);
- event.load("player_post_respawn");
- event.load("function_key");
- //Temp-Kopie von player_list erstellen
- templist = list.new();
- for(i = 0; i < list.getSize(player_list); i++) {
- p_uuid = list.getIndex(player_list, i);
- p = player.get(p_uuid);
- msg.prefix(p, gamename, "The game has started.");
- list.add(templist, p_uuid);
- map.add(points, p_uuid, 0);
- player.setGamemode(p, "survival");
- player.setFly(p, false);
- }
- diapickaxe = read.item("{id:\"minecraft:diamond_pickaxe\",Count:1b,tag:{Enchantments:[{lvl:1s,id:\"minecraft:efficiency\"}]}}");
- blocks512 = read.item("minecraft:cut_sandstone", 512);
- stick = read.item("{id:\"minecraft:stick\",Count:1b,tag:{HideFlags:2,Enchantments:[{lvl:1s,id:\"minecraft:knockback\"}],display:{Name:'{\"text\":\"§bKnüppel\"}'},AttributeModifiers:[{UUIDMost:1,UUIDLeast:1,Amount:100.0d,Slot:\"mainhand\",AttributeName:\"generic.attackSpeed\",Operation:0,Name:\"modifier\"}]}}");
- ironpickaxe = read.item("minecraft:iron_pickaxe");
- blocks64 = read.item("minecraft:cut_sandstone", 64);
- for(i = 0; i < seeker_amount; i++) {
- p_uuid = list.getIndex(templist, math.random(0, list.getSize(templist) - 1));
- p = player.get(p_uuid);
- list.remove(templist, p_uuid);
- setSeeker(p);
- msg.prefix(p, gamename, "Catch other players!");
- }
- for(i = 0; i < list.getSize(templist); i++) {
- p_uuid = list.getIndex(templist, i);
- p = player.get(p_uuid);
- setEscaper(p);
- msg.prefix(p, gamename, "Run away!!!");
- }
- sgoto(20, "loop");
- gosub("updatedisplay");
- @checkgame
- wait();
- if(event == "living_pre_hurt") {
- if(!isPlayer(living_entity)) {
- goto("checkgame");
- }
- player = living_entity;
- }
- if(player.hasMinigameId(player, script_id)) {
- ignoreGoto(event);
- }
- goto("checkgame");
- @function_key
- if(list.contains(seekerlist, player.getUuid(player))) {
- skills_list = seeker_skills;
- type = "seeker";
- } else {
- skills_list = hider_skills;
- type = "hider";
- }
- if(key > list.getSize(skills_list)) {
- goto("checkgame");
- }
- skill = list.getIndex(skills_list, key - 1);
- skill_name = skill[0];
- needed_cooldown = skill[1];
- effecttime = skill[3] * 20;
- amplifier = skill[4];
- offensive = skill[5];
- tech_name = skill[6];
- last_exe_time = getCatchLastExeTime(player, skill_name);
- diff_time = math.roundUp((time.getMillis() - last_exe_time) / 1000);
- if(diff_time < needed_cooldown) {
- player.action(player, concat("§a", text.number(needed_cooldown - diff_time), "s cooldown left"));
- goto("checkgame");
- }
- if(offensive) {
- if(type == "seeker") {
- iter = list.iterator(escaperlist);
- while(hasNext(iter)) {
- p = player.get(next(iter));
- entity.addEffect(p, tech_name, effecttime, amplifier, false);
- }
- } else {
- iter = list.iterator(seekerlist);
- while(hasNext(iter)) {
- p = player.get(next(iter));
- entity.addEffect(p, tech_name, effecttime, amplifier, false);
- }
- }
- } else {
- entity.addEffect(player, tech_name, effecttime, amplifier, false);
- }
- setCatchLastExeTime(player, skill_name);
- status.addTimed(player, key, needed_cooldown * 20, concat("CD ", skill_name));
- minigame.speakAll(gamename, concat("§6", player.getName(player), "§r used §2", skill_name, "."));
- goto("checkgame");
- @living_pre_hurt
- defender = player;
- attacker = player.getFromDamageSource(damage_source);
- if(attacker == null) {
- goto("checkgame");
- }
- defender_uuid = player.getUuid(defender);
- if(!list.contains(player_list, defender_uuid)) {
- cancel = true;
- msg.prefix(attacker, gamename, "§eIllegal player in game.");
- goto("checkgame");
- }
- if(!player.hasMinigameId(attacker, script_id)) {
- goto("checkgame");
- }
- attacker_uuid = player.getUuid(attacker);
- if(defender_uuid == attacker_uuid) {
- goto("checkgame");
- }
- if(!list.contains(player_list, attacker_uuid)) {
- msg.prefix(defender, gamename, "§eIllegal player in game.");
- goto("checkgame");
- }
- if(list.contains(seekerlist, attacker_uuid) && list.contains(escaperlist, defender_uuid)) {
- setSeeker(defender);
- msg.prefix(defender, gamename, "Catch other players!");
- setEscaper(attacker);
- msg.prefix(attacker, gamename, "Run away!!!");
- gosub("updatedisplay");
- }
- goto("checkgame");
- @player_post_respawn
- if(list.contains(escaperlist, player.getUuid(player))) {
- //Random-Seeker zum Escaper machen
- p_uuid = list.getIndex(seekerlist, math.random(0, list.getSize(seekerlist) - 1));
- p = player.get(p_uuid);
- setEscaper(p);
- msg.prefix(p, gamename, "Run away!!!");
- //Escaper wird zum Seeker
- setSeeker(player);
- msg.prefix(player, gamename, "Catch other players!");
- gosub("updatedisplay");
- } else {
- player.clearInventory(player);
- giveSeekerItems(player);
- entity.teleport(player, seeker_spawn_loc);
- }
- goto("checkgame");
- @block_break
- cancel = true;
- if(list.contains(spawnprotect, block_loc)) {
- inv.update(player);
- goto("checkgame");
- }
- if(list.contains(placedblocks, block_loc)) {
- cancel = false;
- list.remove(placedblocks, block_loc);
- goto("checkgame");
- }
- if(set.contains(allowed_breaks, block_type)) {
- cancel = false;
- map.add(brokenblocks, block_loc, block_type);
- goto("checkgame");
- }
- if(block_type == "minecraft:diamond_block") {
- player_uuid = player.getUuid(player);
- if(list.contains(escaperlist, player_uuid)) {
- cancel = false;
- temp = map.get(points, player_uuid) + 1;
- map.add(points, player_uuid, temp);
- if(temp >= winpoints) {
- winner_uuid = player_uuid;
- goto("win");
- }
- sgoto(60, "replacedia");
- goto("checkgame");
- }
- }
- goto("checkgame");
- @block_place
- if(list.contains(spawnprotect, block_loc)) {
- cancel = true;
- inv.update(player);
- goto("checkgame");
- }
- if(block_type == "minecraft:diamond_block") {
- cancel = true;
- inv.update(player);
- goto("checkgame");
- }
- cancel = false;
- list.add(placedblocks, block_loc);
- goto("checkgame");
- @replacedia
- block.set(dia_loc, "minecraft:diamond_block");
- goto("checkgame");
- @loop
- //Zeit wird nur Escapern angezeigt
- for(i = 0; i < list.getSize(escaperlist); i++) {
- p_uuid = list.getIndex(escaperlist, i);
- seconds = map.get(times, p_uuid) - 1;
- if(seconds <= 0) {
- seconds = 30;
- temp = map.get(points, p_uuid) + 2;
- map.add(points, p_uuid, temp);
- if(temp >= winpoints) {
- winner_uuid = p_uuid;
- goto("win");
- }
- }
- map.add(times, p_uuid, seconds);
- }
- sgoto(20, "loop");
- gosub("updatedisplay");
- goto("checkgame");
- @updatedisplay
- minigame.displayResetAll();
- displayindex = 0;
- minigame.displayAll(displayindex++, "§6Catcher");
- for(i = 0; i < list.getSize(seekerlist); i++) {
- minigame.displayAll(displayindex++, player.getName(list.getIndex(seekerlist, i)));
- }
- minigame.displayAll(displayindex++, "");
- minigame.displayAll(displayindex++, concat("§6Points §r(Goal: ", text.number(winpoints), ")"));
- for(i = 0; i < list.getSize(player_list); i++) {
- p_uuid = list.getIndex(player_list, i);
- minigame.displayAll(displayindex++, concat(text.number(map.get(points, p_uuid)), " ", player.getName(p_uuid)));
- }
- for(i = 0; i < list.getSize(escaperlist); i++) {
- p_uuid = list.getIndex(escaperlist, i);
- p = player.get(p_uuid);
- display.add(p, displayindex++, "");
- display.add(p, displayindex++, "§6Counter");
- display.add(p, displayindex++, concat(text.number(map.get(times, p_uuid))));
- }
- return;
- function setSeeker(player) {
- setStackIcons(player, $seeker_skills);
- player_uuid = player.getUuid(player);
- living.setHealth(player, 20);
- player.setHunger(player, 20);
- player.setSaturation(player, 5);
- entity.clearEffects(player);
- player.clearInventory(player);
- list.add($seekerlist, player_uuid);
- list.remove($escaperlist, player_uuid);
- giveSeekerItems(player);
- entity.teleport(player, $seeker_spawn_loc);
- entity.addEffect(player, "slowness", $slowtime, 6);
- entity.addEffect(player, "jump_boost", $slowtime, 128);
- }
- function setEscaper(player) {
- setStackIcons(player, $hider_skills);
- player_uuid = player.getUuid(player);
- living.setHealth(player, 20);
- player.setHunger(player, 20);
- player.setSaturation(player, 5);
- entity.clearEffects(player);
- player.clearInventory(player);
- list.add($escaperlist, player_uuid);
- list.remove($seekerlist, player_uuid);
- player.giveItem(player, $diapickaxe);
- player.giveItem(player, $stick);
- player.giveItem(player, $blocks512);
- map.add($times, player_uuid, 30);
- entity.teleport(player, $escaper_spawn_loc);
- }
- function giveSeekerItems(player) {
- player.giveItem(player, $ironpickaxe);
- player.giveItem(player, $blocks64);
- }
- function setCatchLastExeTime(player, skill_name) {
- player_uuid = player.getUuid(player);
- player_map = map.getOrDefault($cooldown_map, player_uuid, map.new());
- map.add(player_map, skill_name, time.getMillis());
- map.add($cooldown_map, player_uuid, player_map);
- }
- function getCatchLastExeTime(player, skill_name) {
- player_map = map.get($cooldown_map, player.getUuid(player));
- if(player_map == null) {
- return 0;
- }
- return map.getOrDefault(player_map, skill_name, 0);
- }
- function setStackIcons(player, skills_list) {
- stacks.clear(player);
- for(h = 0; h < list.getSize(skills_list); h++) {
- skill = list.getIndex(skills_list, h);
- icon = skill[2];
- stacks.set(player, h, icon);
- }
- stacks.setActive(player, true);
- }
- function addSeekerSkill(skill_name, cooldown, icon, effecttime, amplifier, offensive, tech_name) {
- skill = array.new(7);
- skill[0] = skill_name;
- skill[1] = cooldown; //s
- skill[2] = icon;
- skill[3] = effecttime; //s
- skill[4] = amplifier;
- skill[5] = offensive;
- skill[6] = tech_name;
- list.add($seeker_skills, skill);
- }
- function addHiderSkill(skill_name, cooldown, icon, effecttime, amplifier, offensive, tech_name) {
- skill = array.new(7);
- skill[0] = skill_name;
- skill[1] = cooldown; //s
- skill[2] = icon;
- skill[3] = effecttime; //s
- skill[4] = amplifier;
- skill[5] = offensive;
- skill[6] = tech_name;
- list.add($hider_skills, skill);
- }
- @player_logout
- @player_giveup
- minigame.speakAll(gamename, concat("§6", player.getName(player), " §rhas left the game."));
- script = script.getFromId(script_id);
- minigame.kickPlayer(script, player);
- player_uuid = player.getUuid(player);
- map.remove(points, player_uuid);
- list.remove(seekerlist, player_uuid);
- list.remove(escaperlist, player_uuid);
- if(list.getSize(player_list) < minplayers) {
- minplayers--;
- if(--seeker_amount == 0) {
- winner_uuid = list.getIndex(player_list, 0);
- goto("win");
- }
- }
- if(list.contains(seekerlist, player_uuid)) {
- //Ersatz-Sucher erstellen
- p = player.get(list.getIndex(escaperlist, math.random(0, list.getSize(escaperlist) - 1)));
- setSeeker(p);
- msg.prefix(p, gamename, "A catcher has left. You are a catcher now.");
- gosub("updatedisplay");
- }
- goto("checkgame");
- @win
- winnername = player.getName(winner_uuid);
- for(i = 0; i < list.getSize(player_list); i++) {
- p_uuid = list.getIndex(player_list, i);
- p = player.get(p_uuid);
- msg.prefix(p, gamename, concat("§6", winnername, "§r has won."));
- player.tpGamesLobby(p);
- resetplayer(p);
- money.addBoost(p, math.round(map.get(points, p_uuid)));
-
- p_id = player.getId(p);
- last_record = ranking.getPoints(rankingtable, p_id);
- if(p_uuid == winner_uuid) {
- last_record++;
- }
- playedgames = minigame.getPlayed(p_id, game_short) + 1;
- minigame.setPlayed(p_id, game_short, playedgames);
- ranking.setPoints(rankingtable, p_id, last_record);
-
- minigame.statsHeader(p, gamename, "§e");
- minigame.statsLine(p, "§e", "Played games", text.number(playedgames));
- minigame.statsLine(p, "§e", "Won games", text.number(last_record));
- if(playedgames != 0) {
- minigame.statsLine(p, "§e", "Win ratio", concat(text.number(math.roundComma((last_record / playedgames) * 100, 2)), "%"));
- }
-
- iter = list.iterator(placedblocks);
- while(hasNext(iter)) {
- block.set(next(iter), "minecraft:air");
- }
- iter = map.iterator(brokenblocks);
- while(hasNext(iter)) {
- element = next(iter);
- loc = map.getKey(element);
- type = map.getValue(element);
- block.set(loc, type);
- }
- block.set(dia_loc, "minecraft:diamond_block");
- entity.removeAll("net.minecraft.entity.item.ItemEntity", middleloc, radius);
- }
- script = script.getFromId(script_id);
- minigame.kickAllPlayers(script);
- minigame.term(script, gamesignloc);
- term();
|