123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- event.load("living_pre_hurt");
- event.load("player_move");
- event.load("player_logout");
- event.load("player_giveup");
- event.load("player_join");
- rankingtable = "jumpranks";
- game_short = "jr";
- maxplayers = 1;
- gamesignloc = minigame.getSignLoc("jrmap");
- sign.started(gamesignloc);
- gamename = "§aJump'n'Run";
- jump_sound = sound.get("entity.item.pickup");
- sound_category_ambient = sound.getCategory("ambient");
- color_list = list.new();
- list.add(color_list, "blue");
- list.add(color_list, "red");
- list.add(color_list, "yellow");
- list.add(color_list, "green");
- list.add(color_list, "orange");
- list.add(color_list, "purple");
- list.add(color_list, "white");
- list.add(color_list, "black");
- list.add(color_list, "light_gray");
- list.add(color_list, "gray");
- list.add(color_list, "magenta");
- list.add(color_list, "brown");
- list.add(color_list, "lime");
- list.add(color_list, "cyan");
- list.add(color_list, "light_blue");
- list.add(color_list, "pink");
- wool_list = list.new();
- concrete_list = list.new();
- iter = list.iterator(color_list);
- while(hasNext(iter)) {
- color_string = next(iter);
- list.add(wool_list, concat("minecraft:", color_string, "_wool"));
- list.add(concrete_list, concat("minecraft:", color_string, "_concrete"));
- }
- @wait
- wait();
- if(event == "living_pre_hurt") {
- if(!isPlayer(living_entity)) {
- goto("wait");
- }
- player = living_entity;
- }
- if(player.hasMinigameId(player, script_id)) {
- ignoreGoto(event);
- }
- goto("wait");
- @player_join
- player_record = ranking.getPoints(rankingtable, player);
- server_record = ranking.getPointsFromRank(rankingtable, 1, "DESC", null);
- goto("newgame");
- @newgame
- index = math.random(0, 15);
- wool_block = list.getIndex(wool_list, index);
- concrete_block = list.getIndex(concrete_list, index);
- points = 0;
- display.reset(player);
- display.add(player, 0, "§6Jump'n'Run");
- display.add(player, 1, "Your Points: §e", text.number(points));
- updateDisplayRecords(player, player_record, server_record);
- player.setGamemode(player, "adventure");
- title.clear(player);
- title.setTime(player, 20, 20, 20);
- title.send(player, gamename);
- player.clearInventory(player);
- living.setHealth(player, 20);
- player.setHunger(player, 20);
- player.setSaturation(player, 5);
- x = math.random(5000, 5100);
- z = math.random(5000, 5100);
- previous_loc = loc.new(world.get("games"), x, 15, z);
- entity.teleport(player, loc.mod(previous_loc, 0.5, 1, 0.5));
- goto("newblock");
- @newblock
- a = getRelativeJumpCoords();
- new_loc = getNewLoc(previous_loc, a[0], a[1], a[2]);
- block.set(new_loc, wool_block);
- block.set(previous_loc, concrete_block);
- sound.spawn(new_loc, jump_sound, sound_category_ambient);
- setMoveEvent(new_loc, player.getUuid(player));
- goto("wait");
- @living_pre_hurt
- cancel = true;
- damage_source_type = damage.getType(damage_source);
- if(damage_source_type == "outOfWorld") {
- //sollte der spieler durch das auffangnetz MoveData:fall_id durchfallen und im Void landen, wird er zurückgesetzt
- resetBlocks(previous_loc, new_loc);
- showStats(player, points);
- goto("newgame");
- }
- goto("wait");
- @player_move
- if(id == fall_id) {
- resetBlocks(previous_loc, new_loc);
- showStats(player, points);
- goto("newgame");
- }
- block.set(previous_loc, "minecraft:air");
- previous_loc = new_loc;
- points++;
- display.add(player, 1, "Your Points: §e", text.number(points));
- player.setHunger(player, 20);
- player.setSaturation(player, 5);
- goto("newblock");
- @player_giveup
- @player_logout
- resetBlocks(previous_loc, new_loc);
- showStats(player, points);
- player.setGamemode(player, "survival");
- script = script.getFromId(script_id);
- minigame.kickPlayer(script, player);
- minigame.term(script, gamesignloc);
- term();
- function showStats(player, points) {
- minigame.addPlayed(player, $game_short, 1);
- minigame.statsHeader(player, $gamename, "§e");
- minigame.statsLine(player, "§e", "Points", text.number(points));
- if($player_record < points) {
- ranking.setPoints($rankingtable, player, points);
- minigame.statsLine(player, "§e", "Beat own record by", text.number(points - $player_record));
- $player_record = points;
- }
- if($player_record > $server_record) {
- $server_record = $player_record;
- }
- minigame.statsLine(player, "§e", "Your Record", text.number($player_record));
- minigame.statsLine(player, "§e", "Server Record", text.number($server_record));
- money.addBoost(player, math.round(points));
- }
- function resetBlocks(old_loc, new_loc) {
- block.set(old_loc, "minecraft:air");
- block.set(new_loc, "minecraft:air");
- }
- function updateDisplayRecords(player, player_record, server_record) {
- display.add(player, 2, "Your Record: §e", text.number(player_record));
- display.add(player, 3, "Server Record: §e", text.number(server_record));
- }
- function setMoveEvent(loc, player_uuid) {
- move_loc1 = loc.mod(loc, 0, 1, 0);
- move_loc2 = loc.mod(loc, 1, 2, 1);
- event.addMoveData(move_loc1, move_loc2, -1, -1, player_uuid);
- if($fall_id != null) {
- event.removeMoveData($fall_id);
- }
- fall_loc1 = loc.mod(move_loc1, -10, -10, -10);
- fall_loc2 = loc.mod(move_loc1, 10, -2, 10);
- $fall_id = event.addMoveData(fall_loc1, fall_loc2, -1, -1, player_uuid);
- }
- function getNewLoc(old_loc, x, y, z) {
- new_loc = loc.mod(old_loc, x, y, z);
- if(!block.isAir(new_loc)) {
- new_loc = getNewLoc(old_loc, x, y, z);
- }
- if(loc.getY(new_loc) > 256) {
- loc.setY(new_loc, 256);
- }
- return new_loc;
- }
- function getRelativeJumpCoords() {
- y = math.random(0, 1);
- x = math.random(0, 4);
- if(y == 0) {
- if(x < 2) {
- z = math.random(2, 4);
- } elseif(x < 4) {
- z = math.random(0, 4);
- } elseif(x == 4) {
- z = math.random(0, 3);
- }
- } else {
- if(x == 0) {
- z = math.random(2, 4);
- } elseif(x == 1) {
- z = math.random(2, 3);
- } elseif(x < 4) {
- z = math.random(0, 3);
- } elseif(x == 4) {
- z = 0;
- }
- }
- x = randomSign(x);
- z = randomSign(z);
- a = array.new(3);
- a[0] = x;
- a[1] = y;
- a[2] = z;
- return a;
- }
- function randomSign(value) {
- sign = math.random(0, 1);
- if(sign == 0) {
- return value *= -1;
- }
- return value;
- }
|