123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596 |
- event.load("inv_click");
- event.load("inv_close");
- event.load("item_air_click");
- event.load("player_toss");
- event.load("item_hit");
- event.load("function_key");
- rankingtable = "rmranks";
- game_short = "rm";
- specific_lobby_handling = true;
- no_core_reset = true;
- agelist = list.new();
- gamename = "§cRageMode";
- no_emerald = false;
- gosub("setstart");
- times = map.new();
- time = time.getMillis();
- for(i = 0; i < list.getSize(spawns); i++) {
- map.add(times, list.getIndex(spawns, i), time);
- }
- arrow_type = "minecraft:arrow";
- bow = read.item("{id:\"minecraft:bow\",Count:1b,tag:{Enchantments:[{lvl:1s,id:\"minecraft:infinity\"}],display:{Name:'{\"text\":\"§eRageBow\"}'}}}");
- sword = read.item("minecraft:iron_sword", 1, "§cRageKnife");
- axe = read.item("minecraft:iron_axe", 1, "§bCombatAxe");
- chest = read.item("minecraft:chest", 1, "§7Inventarsortierung");
- arrow = read.item(arrow_type);
- speed = read.item("{id:\"minecraft:potion\",Count:1b,tag:{Potion:\"minecraft:swiftness\"}}");
- item.hide(speed, "potion_effects");
- item.setName(speed, "§eGeschwindigkeit");
- lore_list = list.new();
- list.add(lore_list, "§7Verdopple deine Geschwindigkeit");
- list.add(lore_list, "§rPreis: §a15 Emeralds");
- item.setLore(speed, lore_list);
- lightning = read.item("minecraft:blaze_rod");
- item.setName(lightning, "§eGottes Hand");
- lore_list = list.new();
- list.add(lore_list, "§7Töte deine Gegner mit der Hilfe von Gottes Hand");
- list.add(lore_list, "§rPreis: §a30 Emeralds");
- item.setLore(lightning, lore_list);
- shopmenu = inv.new("220000000");
- inv.setItem(shopmenu, 0, speed);
- inv.setItem(shopmenu, 1, lightning);
- goto("simplelobby");
- @specificLobbyHandling
- if(event == "player_join") {
- resetplayer(player);
- player.setSaturation(player, 1000000);
- display.add(player, 1, gamename);
- display.add(player, 2, "§cTeams are forbidden");
- display.add(player, 3, "§eMap");
- display.add(player, 4, mapname);
- stacks.clear(player);
- stacks.set(player, 0, "minecraft:chest");
- return;
- }
- if(event == "player_toss") {
- cancel = true;
- player.giveItem(player, item);
- inv.update(player);
- return;
- }
- if(event == "inv_close") {
- counter = 0;
- for(i = 0; i <= 8; i++) {
- if(item.getType(inv.getItem(inv, i)) == "minecraft:air") {
- counter++;
- }
- }
- if(counter == 5) {
- msg.prefix(player, gamename, "§eChanges saved.");
- } else {
- saveDefaultInventory(player);
- msg.prefix(player, gamename, "§eInvalid change. Set to default.");
- }
- return;
- }
- if(event == "function_key") {
- if(key == 1) {
- showRmInventory(player);
- }
- return;
- }
- return;
- @finalstart
- player_list = minigame.getPlayers(script_id);
- starttime = time.getMillis();
- kills = map.new();
- theoretickills = list.new();
- deaths = map.new();
- killstreak = map.new();
- maxkillstreak = map.new();
- messerkills = map.new();
- axekills = map.new();
- emeralds = map.new();
- lastposition = map.new();
- nemesis = map.new();
- wither_sound = sound.get("minecraft:entity.wither.spawn");
- join_sound = sound.get("minecraft:block.note_block.harp");
- ambient_sound_category = sound.getCategory("ambient");
- minigame.displayAll(1, "§6RageMode");
- minigame.displayAll(2, "§aGoal: §r25");
- id = 3;
- for(i = 0; i < size; i++) {
- for_p = player.get(list.getIndex(player_list, i));
- for_pname = player.getName(for_p);
- msg.prefix(for_p, gamename, "The game has started.");
- minigame.displayAll(id, concat("0 §8", for_pname));
- display.add(for_p, id, concat("0 §e", for_pname));
- stacks.setActive(player, false);
- id++;
- @position
- position = list.getIndex(spawns, math.random(0, list.getSize(spawns) - 1));
- if(time.getMillis() - map.get(times, position) < 5000) {
- goto("position");
- }
- if(map.get(lastposition, for_pname) == position) {
- goto("position");
- }
- map.add(lastposition, for_pname, position);
- entity.teleport(for_p, position);
- map.add(times, position, time.getMillis());
- sound.spawnForPlayer(for_p, join_sound, ambient_sound_category);
- player.setGamemode(for_p, "survival");
- player.setFly(for_p, false);
-
- player.clearInventory(for_p);
- giveRmInventory(for_p);
- inv.close(for_p);
-
- map.add(kills, for_pname, 0);
- array = array.new(2);
- array[0] = for_pname;
- array[1] = 0;
- list.add(theoretickills, array);
- map.add(deaths, for_pname, 0);
- map.add(killstreak, for_pname, 0);
- map.add(maxkillstreak, for_pname, 0);
- map.add(messerkills, for_pname, 0);
- map.add(axekills, for_pname, 0);
- map.add(emeralds, for_pname, 0);
- }
- minigame.displayAll(id, "Emeralds: §a0");
- sgoto(16800, "lastminute");
- sgoto(18000, "endgame");
- entity.removeAll("net.minecraft.entity.item.ItemEntity", middleloc, radius);
- @wait
- wait();
- if(event == "living_pre_hurt") {
- if(!isPlayer(living_entity)) {
- goto("wait");
- }
- player = living_entity;
- } elseif(event == "item_hit") {
- if(!isPlayer(shooter)) {
- goto("wait");
- }
- player = shooter;
- }
- if(player.hasMinigameId(player, script_id)) {
- player_name = player.getName(player);
- ignoreGoto(event);
- }
- goto("wait");
- @item_hit
- attacker = shooter;
- if(entity_hit != null) {
- entity.remove(projectile);
- attacker_name = player.getName(attacker);
- attacker_uuid = player.getUuid(attacker);
- if(!list.contains(player_list, attacker_uuid)) {
- //Illegaler Spieler
- goto("wait");
- }
- defender = entity_hit;
- defender_uuid = player.getUuid(defender);
- if(!list.contains(player_list, defender_uuid)) {
- //Kein PlayerEntity oder illegaler Spieler
- goto("wait");
- }
- defender_name = player.getName(defender);
- if(defender_uuid == attacker_uuid) {
- goto("wait");
- }
- goto("axeCore");
- }
- goto("wait");
- @block_place
- cancel = true;
- @item_air_click
- player_item_type = item.getType(living.getEquip(player, "hand"));
- if(player_item_type == "minecraft:iron_axe") {
- list.add(agelist, living.shootProjectile(player, "me.km.entities.EntityItemProjectile", 1, axe));
- sgoto(10, "setage");
- player.removeItem(player, living.getEquip(player, "hand"));
- goto("wait");
- }
- if(player_item_type == "minecraft:chest") {
- inv.open(shopmenu, player, "§8Shop");
- }
- goto("wait");
- @living_pre_hurt
- cancel = true;
- defender = player;
- defender_name = player.getName(defender);
- defender_uuid = player.getUuid(defender);
- if(!list.contains(player_list, defender_uuid)) {
- msg.prefix(player, gamename, "§eIllegal player in game.");
- goto("wait");
- }
- attacker = player.getFromDamageSource(damage_source);
- if(attacker == null) {
- goto("wait");
- }
- attacker_uuid = player.getUuid(attacker);
- if(!player.hasMinigameId(attacker, script_id)) {
- goto("wait");
- }
- attacker_name = player.getName(attacker);
- if(defender_uuid == attacker_uuid) {
- goto("wait");
- }
- if(!list.contains(player_list, attacker_uuid)) {
- msg.prefix(player, gamename, "§eIllegal player in game.");
- goto("wait");
- }
- attacker_item = living.getEquip(attacker, "hand");
- attacker_item_type = item.getType(attacker_item);
- if(attacker_item_type == "minecraft:iron_axe") {
- player.removeItem(attacker, attacker_item);
- goto("axeCore");
- } elseif(attacker_item_type == "minecraft:iron_sword") {
- map.add(messerkills, attacker_name, map.get(messerkills, attacker_name) + 1);
- } elseif(attacker_item_type == "minecraft:air") {
- goto("wait");
- }
- msg.prefix(attacker, gamename, concat("§eYou killed §8", defender_name, "."));
- msg.prefix(defender, gamename, concat("§8", attacker_name, " §ekilled you."));
- gosub("core");
- goto("wait");
- @inv_click
- cancel = true;
- if(item.getType(item) != "minecraft:air") {
- emeraldid = 3 + list.getSize(player_list);
- if(inv_slot == 0) {
- if(map.get(emeralds, player_name) >= 15) {
- entity.addEffect(player, "speed", 1200, 4);
- map.add(emeralds, player_name, map.get(emeralds, player_name) - 15);
- display.add(player, emeraldid, "Emeralds: §a", text.number(map.get(emeralds, player_name)));
- minigame.speakAll(gamename, concat("§8", player_name, "§e setzt Geschwindigkeit ein"));
- inv.close(player);
- }
- } elseif(inv_slot == 1) {
- if(map.get(emeralds, player_name) >= 30) {
- minigame.speakAll(gamename, concat("§8", player_name, "§e hat Gottes Hand verwendet"));
- inv.close(player);
- map.add(emeralds, player_name, map.get(emeralds, player_name) - 30);
- no_emerald = true;
- attacker = player;
- attacker_name = player_name;
- display.add(player, emeraldid, "Emeralds: §a", text.number(map.get(emeralds, player_name)));
- for(i = 0; i < list.getSize(player_list); i++) {
- defender = player.get(list.getIndex(player_list, i));
- defender_name = player.getName(defender);
- if(defender != attacker) {
- gosub("core");
- msg.prefix(attacker, gamename, concat("§eYou killed §8", defender_name, "."));
- msg.prefix(defender, gamename, concat("§8", attacker_name, " §ekilled you."));
- }
- }
- no_emerald = false;
- }
- }
- }
- goto("wait");
- @block_break
- cancel = true;
- goto("wait");
- @player_toss
- cancel = true;
- player.giveItem(player, item);
- inv.update(player);
- goto("wait");
- @setage
- temp = list.getIndex(agelist, 0);
- item.entity.setLifespan(temp, 390);
- list.removeIndex(agelist, 0);
- goto("wait");
- @axeCore
- action = "axeHit";
- sound.spawnForPlayer(defender, wither_sound, ambient_sound_category);
- msg.prefix(attacker, gamename, concat("§eYou killed §8", defender_name, " §ewith you axe."));
- msg.prefix(defender, gamename, concat("§8", attacker_name, " §ekilled you with his axe."));
- msg.prefix(defender, gamename, "Your Kills: §c-25§r%");
- map.add(axekills, attacker_name, map.get(axekills, attacker_name) + 1);
- setTheoreticKills(defender_name, math.rounddown(getTheoreticKills(defender_name) * 0.75));
- gosub("core");
- goto("wait");
- @core
- emeraldid = 3 + list.getSize(player_list);
- if(!no_emerald) {
- msg.prefix(attacker, gamename, "§e+§r1 §aEmerald");
- map.add(emeralds, attacker_name, map.get(emeralds, attacker_name) + 1);
- display.add(attacker, emeraldid, "Emeralds: §a", text.number(map.get(emeralds, attacker_name)));
- }
- if(defender_name == map.get(nemesis, attacker_name)) {
- msg.prefix(attacker, gamename, "§eYou killed your §cNemesis enemy.");
- msg.prefix(attacker, gamename, "§e+§r1 §aEmerald");
- map.add(emeralds, attacker_name, map.get(emeralds, attacker_name) + 1);
- display.add(attacker, emeraldid, "Emeralds: §a", text.number(map.get(emeralds, attacker_name)));
- }
- map.add(deaths, defender_name, map.get(deaths, defender_name) + 1);
- map.add(kills, attacker_name, map.get(kills, attacker_name) + 1);
- incTheoreticKills(attacker_name);
- player.clearInventory(defender);
- player.setSaturation(defender, 1000000);
- player.setSaturation(attacker, 1000000);
- map.add(nemesis, defender_name, attacker_name);
- map.add(nemesis, attacker_name, null);
- map.add(killstreak, defender_name, 0);
- map.add(killstreak, attacker_name, map.get(killstreak, attacker_name) + 1);
- if(map.get(killstreak, attacker_name) > map.get(maxkillstreak, attacker_name)) {
- map.add(maxkillstreak, attacker_name, map.get(maxkillstreak, attacker_name) + 1);
- }
- giveRmInventory(defender);
- sortTheoreticKills();
- printTheoreticKills();
- @newposition
- position = list.getIndex(spawns, math.random(0, list.getSize(spawns) - 1));
- if(time.getMillis() - map.get(times, position) < 5000) {
- goto("newposition");
- }
- if(map.get(lastposition, defender_name) == position) {
- goto("newposition");
- }
- map.add(lastposition, defender_name, position);
- entity.teleport(defender, position);
- if(action == "axeHit") {
- sound.spawnForPlayer(defender, wither_sound, ambient_sound_category);
- }
- action = null;
- map.add(times, position, time.getMillis());
- if(getTheoreticKills(attacker_name) >= 25) {
- winner_name = attacker_name;
- goto("wincore");
- }
- return;
- @endgame
- sortTheoreticKills();
- array = list.getIndex(theoretickills, 0);
- winner_name = array[0];
- goto("wincore");
- @player_logout
- @player_giveup
- removeFromTheoreticKills(player_name);
- script = script.getFromId(script_id);
- minigame.kickPlayer(script, player);
- player_id = player.getId(player);
- minigame.setPlayed(player_id, game_short, minigame.getPlayed(player_id, game_short) + 1);
- minigame.displayResetAll();
- sortTheoreticKills();
- printTheoreticKills();
- if(list.getSize(player_list) <= 1) {
- winner_name = player.getName(player.get(list.getIndex(player_list, 0)));
- goto("wincore");
- }
- goto("wait");
- @lastminute
- minigame.speakAll(gamename, "60 seconds left.");
- goto("wait");
- @wincore
- endtime = time.getMillis();
- time = math.round((endtime - starttime) / 1000);
- for(i = 0; i < list.getSize(player_list); i++) {
- puuid = list.getIndex(player_list, i);
- p = player.get(puuid);
- pname = player.getName(p);
- p_id = player.getId(p);
-
- last_record = ranking.getPoints(rankingtable, p_id);
- record = last_record + map.get(kills, pname);
- playedgames = minigame.getPlayed(p_id, game_short) + 1;
- minigame.setPlayed(p_id, game_short, playedgames);
- ranking.setPoints(rankingtable, p_id, record);
- wongames = minigame.getWon(p, "rm");
- if(pname == winner_name) {
- winningtext = "Yes";
- wongames++;
- minigame.setWon(p, "rm", wongames);
- money.addBoost(p, 128);
- } else {
- winningtext = "No";
- money.addBoost(p, 32);
- }
-
- msg.prefix(p, gamename, concat("§8", winner_name, " §ehas won §cRageMode."));
-
- minigame.statsHeader(p, gamename, "§e");
- minigame.statsLine(p, "§e", "Time", concat(text.number(math.round(time / 60)), " Minuten ", text.number(time % 60), " Sekunden"));
- minigame.statsLine(p, "§e", "Kills", text.number(map.get(kills, pname)));
- minigame.statsLine(p, "§e", "Killstreak", text.number(map.get(maxkillstreak, pname)));
- minigame.statsLine(p, "§e", "Sword-Kills", text.number(map.get(messerkills, pname)));
- minigame.statsLine(p, "§e", "Axe-Kills", text.number(map.get(axekills, pname)));
- minigame.statsLine(p, "§e", "Deaths", text.number(map.get(deaths, pname)));
- minigame.statsLine(p, "§e", "Won games", text.number(wongames));
- minigame.statsLine(p, "§e", "Played games", text.number(playedgames));
- if(playedgames != 0) {
- minigame.statsLine(p, "§e", "Win ratio", concat(text.number(math.roundComma((wongames / playedgames) * 100, 2)), "%"));
- }
- minigame.statsLine(p, "§e", "Won", winningtext);
- }
- entity.removeAll("net.minecraft.entity.item.ItemEntity", middleloc, radius);
- script = script.getFromId(script_id);
- minigame.kickAllPlayers(script);
- minigame.term(script, gamesignloc);
- term();
- function setTheoreticKills(player_name, points) {
- for(i = 0; i < list.getSize($theoretickills); i++) {
- array = list.getIndex($theoretickills, i);
- if(array[0] == player_name) {
- array[1] = points;
- break;
- }
- }
- }
- function getTheoreticKills(player_name) {
- for(i = 0; i < list.getSize($theoretickills); i++) {
- array = list.getIndex($theoretickills, i);
- if(array[0] == player_name) {
- points = array[1];
- break;
- }
- }
- return points;
- }
- function incTheoreticKills(player_name) {
- setTheoreticKills(player_name, getTheoreticKills(player_name) + 1);
- }
- function removeFromTheoreticKills(player_name) {
- for(i = 0; i < list.getSize($theoretickills); i++) {
- array = list.getIndex($theoretickills, i);
- if(array[0] == player_name) {
- list.removeIndex($theoretickills, i);
- break;
- }
- }
- }
- function getIndexFromPlayer(player_name) {
- for(i = 0; i < list.getSize($theoretickills); i++) {
- array = list.getIndex($theoretickills, i);
- if(array[0] == player_name) {
- return i;
- }
- }
- return null; //Nemesisgegner ist geleavt
- }
- function sortTheoreticKills() {
- size = list.getSize($theoretickills);
- swapped = true;
- while(swapped) {
- swapped = false;
- for(i = 0; i < size - 1; i++) {
- array = list.getIndex($theoretickills, i);
- array2 = list.getIndex($theoretickills, i + 1);
- zahl1 = array[1];
- zahl2 = array2[1];
- if(zahl1 < zahl2) {
- list.setIndex($theoretickills, i, array2);
- list.setIndex($theoretickills, i + 1, array);
- swapped = true;
- }
- }
- }
- }
- function printTheoreticKills() {
- id = 3;
- for(i = 0; i < list.getSize($theoretickills); i++) {
- array = list.getIndex($theoretickills, i);
- disp_pname = array[0];
- disp_p = read.player(disp_pname);
- points = text.number(array[1]);
- minigame.displayAll(id, concat(points, " §8", disp_pname));
- display.add(disp_p, id, concat(points, " §e", disp_pname));
- id++;
- }
- for(i = 0; i < list.getSize($player_list); i++) {
- disp_p = player.get(list.getIndex($player_list, i));
- disp_pname = player.getName(disp_p);
- nemesis_name = map.get($nemesis, disp_pname);
- if(nemesis_name != null) {
- index = getIndexFromPlayer(nemesis_name);
- if(index != null) {
- display.add(disp_p, 3 + index, concat(text.number(getTheoreticKills(nemesis_name)), " §c", nemesis_name));
- }
- }
- }
- }
- function giveRmInventory(player) {
- inv = getRmInventory(player);
- @tryagain
- counter = 0;
- player_inv = player.getInv(player);
- for(i = 0; i <= 8; i++) {
- item = inv.getItem(inv, i);
- if(item.getType(item) == "minecraft:air") {
- counter++;
- }
- inv.setItem(player_inv, i, item);
- }
- if(counter != 5) {
- inv = saveDefaultInventory(player);
- msg.prefix(player, $gamename, "§eUngültiges Inventar erkannt. Default-Inventar wird verwendet.");
- goto("tryagain");
- }
- inv.setItem(player_inv, 9, $arrow);
- }
- function showRmInventory(player) {
- rm_inv = getRmInventory(player);
- inv.open(rm_inv, player, "§8Inventar");
- }
- function getRmInventory(player) {
- map = getScriptVar("rmInventories");
- inv = map.get(map, player.getUuid(player));
- if(inv == null) {
- inv = saveDefaultInventory(player);
- }
- return inv;
- }
- function saveDefaultInventory(player) {
- rm_inv = inv.new("111111111");
- bow = bow = read.item("{id:\"minecraft:bow\",Count:1b,tag:{Enchantments:[{lvl:1s,id:\"minecraft:infinity\"}],display:{Name:'{\"text\":\"§eRageBow\"}'}}}");
- sword = read.item("minecraft:iron_sword", 1, "§cRageKnife");
- axe = read.item("minecraft:iron_axe", 1, "§bCombatAxe");
- chest = read.item("minecraft:chest", 1, "§aShop");
- inv.setItem(rm_inv, 0, bow);
- inv.setItem(rm_inv, 1, sword);
- inv.setItem(rm_inv, 2, axe);
- inv.setItem(rm_inv, 8, chest);
- saveRmInventory(player, rm_inv);
- return rm_inv;
- }
- function saveRmInventory(player, inv) {
- map = getScriptVar("rmInventories");
- map.add(map, player.getUuid(player), inv);
- setScriptVar("rmInventories", map);
- }
|