123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843 |
- rankingtable = "snowranks";
- game_short = "snow";
- game_tab = "§6SNOW";
- minigame.setSpecificLobbyHandling(true);
- minigame.setPlayerResetInCore(false);
- minigame.setIndivStartCheck(true);
- gamename = "§6Snowfight";
- snow_stack = item.create("minecraft:snowball", 16, null, null);
- Air = material.get("AIR");
- B_Candle = material.get("BLACK_CANDLE");
- B_Concrete = material.get("BLACK_CONCRETE"); //for black hole
- W_Concrete = material.get("WHITE_CONCRETE"); //for white hole
- pling_sound = sound.get("BLOCK_AMETHYST_BLOCK_CHIME"); //snowball hits candle
- Nom_sound = sound.get("ENTITY_GENERIC_EAT"); //snowball hits hole
- sound_Category = sound.getCategory("MASTER");
- snow_particle = particle.get("SNOWFLAKE");
- smokeparticle = particle.get("SMOKE_LARGE");
- fire_particle = particle.get("FLAME");
- gravitors = list.new();
- toggled_black_holes = list.new();
- toggled_white_holes = list.new();
- relit_candles = list.new();
- grav_locs = list.new();
- colorcodes = map.new();
- map.add(colorcodes, 0, "§1");
- map.add(colorcodes, 1, "§4");
- map.add(colorcodes, 2, "§e");
- map.add(colorcodes, 3, "§2");
- teamcolortext = map.new();
- map.add(teamcolortext, 0, "§1blue");
- map.add(teamcolortext, 1, "§4red");
- map.add(teamcolortext, 2, "§eyellow");
- map.add(teamcolortext, 3, "§2green");
- teamcolortext2 = map.new();
- map.add(teamcolortext2, 0, "§1Blue");
- map.add(teamcolortext2, 1, "§4Red");
- map.add(teamcolortext2, 2, "§eYellow");
- map.add(teamcolortext2, 3, "§2Green");
- cloth_color = map.new();
- map.add(cloth_color, 0, 3361970);
- map.add(cloth_color, 1, 10040115);
- map.add(cloth_color, 2, 16701501);
- map.add(cloth_color, 3, 84395831);
- team_lists = map.new(); //Map mit Spielerlisten für jedes Team
- map.add(team_lists, 0, list.new());
- map.add(team_lists, 1, list.new());
- map.add(team_lists, 2, list.new());
- map.add(team_lists, 3, list.new());
- players = map.new(); //Alle Spieler (key) des Spiels und deren Teamzugehörigkeit (value)
- allteams = list.new(); //Alle Teams, die noch im Spiel sind
- waiters = list.new(); //Spieler in der Lobby ohne Teamzugehörigkeit
- spawn_prot = list.new();
- lifes = map.new();
- kills_map = map.new();
- deaths_map = map.new();
- cooldown_map = map.new();
- snowball = material.get("snowball");
- minigame.initStart();
- goto("simplelobby");
- @specificLobbyHandling
- player_name = player.getName(player);
- if(event == "minigame_join") {
- list.add(waiters, player_name);
- map.add(kills_map, player_name, 0);
- map.add(deaths_map, player_name, 0);
- living.setHealth(player, 20);
- player.setHunger(player, 20);
- player.setSaturation(player, 5);
- player.clearInventory(player);
- sb.add(player, 99, gamename);
- sb.add(player, 98, string.concat("Map: ", mapname));
- sb.add(player, 97, "2x10");
- sb.add(player, 96, sb.getSpacer());
- return;
- }
- if(event == "player_quit" || event == "player_giveup") {
- list.remove(waiters, player_name);
- team = map.get(players, player_name);
- if(team != null) {
- teamlist = map.get(team_lists, team);
- list.remove(teamlist, player_name);
- }
- map.remove(players, player_name);
- return;
- }
- if(event == "block_click") {
- if(slot.isOffHand(hand)) {
- return;
- }
- if(action != "RIGHT_CLICK_BLOCK") {
- return;
- }
- block_loc = block.getLocation(block);
- if(list.contains(joinblocks, block_loc)) {
- newteam = list.getIndexOf(joinblocks, block_loc);
- newteamlist = map.get(team_lists, newteam);
- if(list.contains(newteamlist, player_name)) {
- msg.prefix(player, gamename, "§eYou are already in this team.");
- return;
- }
- if(list.getSize(newteamlist) >= teamsize) {
- msg.prefix(player, gamename, "§eNo space for you in this team.");
- return;
- }
- list.remove(waiters, player_name);
- yetteam = map.get(players, player_name);
- if(yetteam != null) {
- yetteamlist = map.get(team_lists, yetteam);
- list.remove(yetteamlist, player_name);
- }
- list.add(newteamlist, player_name);
- map.add(players, player_name, newteam);
- msg.prefix(player, gamename, string.concat("§eYou joined the ", map.get(teamcolortext, newteam), " §eteam."));;
- if(!minigame.isStarting()) {
- goto("startcountdown");
- }
- }
- }
- return;
- @finalstart
- player_list = minigame.getPlayers(script_id);
- starttime = time.getMillis();
- event.load("projectile_hit");
- event.load("player_drop");
- event.load("living_death");
- event.load("player_post_respawn");
- event.load("entity_spawn");
- event.load("entity_remove");
- event.load("arm_swing");
- //event.load("block_click"); //for polarity change, currently not active
- event.load("player_move");
- while(list.getSize(waiters) != 0) {
- team = getTeamWithLowestPeople(team_lists, numberofteams);
- teamlist = map.get(team_lists, team);
- p_name = list.getIndex(waiters, 0);
- map.add(players, p_name, team);
- list.add(teamlist, p_name);
- list.remove(waiters, p_name);
- }
- max = 1;
- for(i = 0; i < numberofteams; i++) {
- teamlist = map.get(team_lists, i);
- size = list.getSize(teamlist);
- if(size > max) {
- max = size;
- }
- }
- team_lifes = max * 10;
- sb.clearGameAll();
- minigame.displayAll(99, gamename);
- for(i = 0; i < numberofteams; i++) {
- teamlist = map.get(team_lists, i);
- size = list.getSize(teamlist);
- if(size != 0) {
- list.add(allteams, i);
- map.add(lifes, i, team_lifes);
- minigame.displayAll(98 - i, string.concat(map.get(teamcolortext2, i), " Lifes: ", string.number(team_lifes)));
- }
- }
- minigame.displayAll(98 - i, sb.getSpacer());
- for(i = 0; i < list.getSize(player_list); i++) {
- p = player.get(list.getIndex(player_list, i));
- p_name = player.getName(p);
- msg.prefix(p, gamename, "The game has started.");
- team = map.get(players, p_name);
- giveSnowballs(p);
- player.setHunger(p, 20);
- player.setSaturation(p, 5);
- player.setGamemode(p, "SURVIVAL");
- player.setFly(p, false);
- entity.teleport(p, map.get(spawnlocs, team));
- color = map.get(colorcodes, team);
- player.action(p, text.new(string.concat(color, "Team ", map.get(teamcolortext2, team))));
- equipPlayer(p, team);
- minigame.setTabName(p, game_tab, color);
- }
- sgoto(40, "loop");
- @checkgame
- wait();
- if(event == entity_spawn){
- goto("entity_spawn");
- }
- elseif (event == "entity_remove"){
- goto("entity_remove");
- }
- if(event == "living_death") {
- if(!isPlayer(living_entity)) {
- goto("checkgame");
- }
- player = living_entity;
- }
- if(event == "entity_damage") {
- if(!isPlayer(entity)) {
- goto("checkgame");
- }
- player = entity;
- }
- if(event == "projectile_hit") {
- if(shooter == null || !isPlayer(shooter)) {
- goto("checkgame");
- }
- player = shooter;
- }
- if(player.hasMinigameId(player, script_id)) {
- player_name = player.getName(player);
- ignoreGoto(event);
- }
- goto("checkgame");
- @entity_spawn
- //if there is a new snowball in game, add it to gravitation
- if (entity.getType(entity) != "snowball"){
- goto("checkgame");
- }
- if (get_distance(entity) > 100){
- goto("checkgame");
- }
- entity.setGravity(entity, false);
- list.add(gravitors, entity);
- Snow.gravitate(entity);
- if (list.getSize(gravitors) == 1){
- sgoto(1, "gravitation");
- }
- goto("checkgame");
- @entity_remove
- //if snowball hits smth, remove it
- //if it hits a black hole or candles doshit
- if (Snow.check(entity)){
- goto("checkgame");
- }
- list.remove(gravitors, entity);
- ent_loc = entity.getLocation(entity);
- motion = entity.getMotion(entity);
- for (i = 0; i<5; i++){
- hit_block = block.get(ent_loc);
- Material = block.getType(hit_block);
- if (Material != Air){
- break;
- }
- loc.add(ent_loc, motion[0]/5, motion[1]/5, motion[2]/5);
- }
- if (Material == B_Candle){
- sound.spawn(ent_loc, pling_sound, sound_Category, 1, 1);
- if (list.contains(relit_candles, hit_block)){
- goto("checkgame");
- }
- loc = block.getLocation(hit_block);
- loc.add(loc,0.5, 0.8, 0.5);
- particle.spawn(loc, smokeparticle, 5, 0.1);
- list.add(relit_candles, hit_block);
- Candle.change_lit(hit_block);
- sgoto(100, "candle");
- }
- elseif (Material == B_Concrete){
- if (!(list.contains(black_holes, ent_loc) || list.contains(white_holes, ent_loc))){
- goto("checkgame");
- }
- sound.spawn(ent_loc, Nom_sound, sound_Category, 1, 1);
- }
- goto("checkgame");
- @arm_swing
- if (get_distance(player) > 100){
- goto("checkgame");
- }
- if (!player.isSneaking(player)){
- goto("checkgame");
- }
- if (item.getType(living.getEquip(player, hand)) != snowball){
- goto("checkgame");
- }
- Snow.aimassist(player);
- goto("checkgame");
- @block_click
- goto("checkgame");//currently not on
- //change polarity of holes if they are clicked
- if (get_distance(player) > 100){
- goto("checkgame");
- }
- if (action != "RIGHT_CLICK_BLOCK"){
- goto("checkgame");
- }
- bool = !bool;
- if (bool){
- goto("checkgame");
- }
- Material = block.getType(block);
- loc = block.getLocation(block);
- loc.add(loc,0.5,0.5,0.5);
- if (Material == B_Concrete){
- if (list.contains(black_holes, loc)){
- list.remove(black_holes, loc);
- list.add(white_holes, loc);
- block.setMaterial(block, W_Concrete);
- }
- }
- elseif (Material == W_Concrete){
- if (list.contains(white_holes, loc)){
- list.remove(white_holes, loc);
- list.add(black_holes, loc);
- block.setMaterial(block, B_Concrete);
- }
- }
- //entity_click doesn't work on snowballs so this is currently useless, but would work in theory
- /*elseif (event == "entity_click"){
- if (Snow.check(entity)){
- goto("wait");
- }
- motion_ball = entity.getMotion(entity);
- motion_player = entity.getMotion(player);
- speed = math.sqrt(math.pow(motion_ball[0]-motion_player[0],2), math.pow(motion_ball[1]-motion_player[1],2), math.pow(motion_ball[2]-motion_player[2],2));
- if (speed > 5.5){
- goto("wait");
- }
- itemstack = item.new(snowball, 1);
- entity.remove(entity);
- player.giveItem(player, itemstack);
- }*/
- goto("checkgame");
- @player_move
- //player off map
- if (id == edge){
- //Snow.launchback(player);
- if (list.getSize(gravitors) == 0){
- sgoto(1, "gravitation");
- }
- entity.setGravity(player, false);
- entity.setMotion(player, 0, 0.2, 0);
- list.add(gravitors, player);
- Snow.gravitate(player);
- }
- elseif (id == fall){
- if (!list.contains(gravitors, player)){
- goto("checkgame");
- }
- list.remove(gravitors, player);
- @fall
- entity.setGravity(player, true);
- //Snow.setback(player); deprecated
- player_name = player.getName(player);
- hit_team = map.get(players, player_name);
- player.clearInventory(player);
- giveSnowballs(player);
- map.add(deaths_map, player_name, map.get(deaths_map, player_name) + 1);
- new_lifes = map.get(lifes, hit_team) - 1;
- map.add(lifes, hit_team, new_lifes);
- minigame.displayAll(98 - hit_team, string.concat(map.get(teamcolortext2, hit_team), " Lifes: ", string.number(new_lifes)));
- loc = map.get(spawnlocs, hit_team);
- entity.teleport(player, loc);
- if(new_lifes == 0) {
- colorgameover(hit_team);
- }
- }
- goto("checkgame");
- @projectile_hit
- if(entity_hit != null) {
- if(!isPlayer(entity_hit)) {
- goto("checkgame");
- }
- entity_hit_name = player.getName(entity_hit);
- if(!list.contains(player_list, player.getUuid(entity_hit))) {
- minigame.msgAll(string.concat("Illegal Player ", entity_hit_name));
- goto("checkgame");
- }
- if(!list.contains(player_list, player.getUuid(player))) {
- minigame.msgAll(string.concat("Illegal Player ", entity_hit_name));
- goto("checkgame");
- }
- player_id = player.getId(entity_hit);
- if(list.contains(spawn_prot, player_id)) {
- goto("checkgame");
- }
- team = map.get(players, player_name);
- hit_team = map.get(players, entity_hit_name);
- if(team == hit_team) {
- goto("checkgame"); //Friendly-Firedly-Fire
- }
- player.clearInventory(entity_hit);
- giveSnowballs(entity_hit);
- map.add(kills_map, player_name, map.get(kills_map, player_name) + 1);
- map.add(deaths_map, entity_hit_name, map.get(deaths_map, entity_hit_name) + 1);
- new_lifes = map.get(lifes, hit_team) - 1;
- map.add(lifes, hit_team, new_lifes);
- minigame.displayAll(98 - hit_team, string.concat(map.get(teamcolortext2, hit_team), " Lifes: ", string.number(new_lifes)));
- loc = map.get(spawnlocs, hit_team);
- entity.teleport(entity_hit, loc);
- if(new_lifes == 0) {
- colorgameover(hit_team);
- }
- list.add(spawn_prot, player_id);
- sgoto(80, "remove_prot");
- }
- goto("checkgame");
- @remove_prot
- list.removeIndex(spawn_prot, 0);
- goto("checkgame");
- @player_post_respawn
- team = map.get(players, player_name);
- loc = map.get(spawnlocs, team);
- entity.teleport(player, loc);
- giveSnowballs(player);
- goto("checkgame");
- @living_death
- list.clear(drops);
- goto("checkgame");
- @entity_damage
- damage_type = damage.getType(damage_source);
- if(damage_type == "wither") {
- goto("checkgame");
- }
- if(cause == "FALL"){
- if (loc.getY(entity.getLocation(player)) <= loc.getY(edge_2)){
- cancel = true;
- goto("fall");
- }
- }
- cancel = true;
- goto("checkgame");
- @player_drop
- cancel = true;
- goto("checkgame");
- @block_break
- @block_place
- cancel = true;
- goto("checkgame");
- @loop
- for(i = 0; i < list.getSize(player_list); i++) {
- p = player.get(list.getIndex(player_list, i));
- p_name = player.getName(p);
- team = map.get(players, p_name);
- player.setHunger(p, 20);
- player.setSaturation(p, 5);
- player.action(p, text.new(string.concat(map.get(colorcodes, team), "Team ", map.get(teamcolortext2, team))));
- equipPlayer(p, team);
- }
- sgoto(40, "loop");
- goto("checkgame");
- @player_giveup
- @player_quit
- team = map.get(players, player_name);
- color = map.get(colorcodes, team);
- minigame.speakAll(gamename, string.concat(color, player_name, " §ehas left the game."));
- teamlist = map.get(team_lists, team);
- list.remove(teamlist, player_name);
- map.remove(players, player_name);
- script = script.getFromId(script_id);
- minigame.kickplayer(script, player);
- if(list.getSize(teamlist) == 0) {
- colorgameover(team);
- }
- goto("checkgame");
- @gravitation
- //adds gravitational pull to entitys in the gravitors list
- //grav_locs = gravitors_loc();
- list_iterator = iterator(gravitors);
- while(hasnext(list_iterator)){
- entity = next(list_iterator);
- Snow.gravitate(entity);
- //particle.spawn(entity.getLocation(entity), snow_particle);
- if (isPlayer(entity)){
- if (get_distance(entity) < 10){
- motion = entity.getMotion(entity);
- entity.setMotion(entity, motion[0]/5, motion[1]/5, motion[2]/5);
- entity.setGravity(entity, true);
- remove(list_iterator);
- }
- }
- elseif (get_distance(entity) > 100){
- remove(list_iterator);
- entity.remove(entity);
- }
- }
- if(list.getSize(gravitors)>0){
- sgoto(5, "gravitation");
- }
- goto("checkgame");
- @candle
- //relights the candles
- b_candle_block = list.getIndex(relit_candles, 0);
- loc = block.getLocation(b_candle_block);
- loc.add(loc,0.5, 0.5, 0.5);
- particle.spawn(loc, fire_particle, 5, 0.1);
- Candle.change_lit(b_candle_block);
- list.removeIndex(relit_candles, 0);
- goto("checkgame");
- function Snow.end(){
- //if script is supposed to end, remove snowballs and light candles
- list_iterator = iterator($relit_candles);
- while(hasnext(list_iterator)){
- b_candle_block = next(list_iterator);
- Candle.change_lit(b_candle_block);
- remove(list_iterator);
- }
- list_iterator = iterator($gravitors);
- while(hasnext(list_iterator)){
- entity = next(list_iterator);
- entity.setGravity(entity, true);
- if (!isPlayer(entity)){
- remove(list_iterator);
- entity.remove(entity);
- }
- }
- }
- function Snow.toggle_grav(){
- //toggles which holes are on, if none are stored in toggled_lists, then it turns gravity on
- temp = $toggled_black_holes;
- $toggled_black_holes = $black_holes;
- $black_holes = temp;
-
- temp = $toggled_white_holes;
- $toggled_white_holes = $white_holes;
- $white_holes = temp;
-
- if (list.getSize($black_holes) + list.getSize($white_holes) == 0){
- list_iterator = iterator($gravitors);
- while(hasnext(list_iterator)){
- entity = next(list_iterator);
- entity.setGravity(entity, true);
- }
- }
- elseif(list.getSize($toggled_black_holes) + list.getSize($toggled_white_holes) == 0){
- list_iterator = iterator($gravitors);
- while(hasnext(list_iterator)){
- entity = next(list_iterator);
- entity.setGravity(entity, false);
- }
- }
- }
- function Snow.check(entity){
- if (entity.getType(entity) != "snowball"){
- return true;
- }
- if (get_distance(entity) > 100){
- return true;
- }
- if (!list.contains($gravitors, entity)){
- return true;
- }
- return false;
- }
- function Candle.change_lit(hit_block){
- //negates the boolean of the blocktag "lit"
- block_data = block.getData(hit_block);
- blockdata_string = string.blockData(block_data);
- blockdata_string = string.replace(blockdata_string, "lit=true", "lit=temp");
- blockdata_string = string.replace(blockdata_string, "lit=false", "lit=true");
- blockdata_string = string.replace(blockdata_string, "lit=temp", "lit=false");
- block_data = read.blockData(blockdata_string);
- block.setData(hit_block, block_data, false);
- }
- function Snow.launchback(player){
- //throws the player towards the black Hole (currently not in use)
- loc = entity.getLocation(player);
- motion = entity.getMotion(player);
- acc = Snow.get_acc(loc);
- x = -motion[0] + 2*acc[0];
- y = 2 + 4*acc[0];
- z = -motion[2] + 2*acc[0];
- entity.setMotion(player, x, y, z);
- }
- function Snow.setback(player){
- //resets the player to a spawn Location
- size = list.getSize($spawn_locs)-1;
- random = math.random(0,size);
- spawn_loc = list.getIndex($spawn_locs, random);
- entity.teleport(player, spawn_loc);
- entity.setMotion(player, 0, 0.5, 0);
- }
- function remove_snowballs(loc){
- //removes (currently just gives gravity etc) snowballs in a radius of the middle Location
- entity_list = entity.near(loc, 50);
- list_iterator = iterator(entity_list);
- while(hasnext(list_iterator)){
- ent = next(list_iterator);
- if (entity.getType(ent) == "snowball"){
- entity.setGravity(ent, true);
- list.add($gravitors, ent);
- //entity.remove(ent);
- }
- }
- }
- function get_distance(entity_){
- //returns the distance of an entity to the middle Location
- ent_loc = entity.getLocation(entity_);
- if (loc.getWorld($middleloc) != loc.getWorld(ent_loc)){
- return 50000;
- }
- x_dist = loc.getX($middleloc) - loc.getX(ent_loc);
- y_dist = loc.getY($middleloc) - loc.getY(ent_loc);
- z_dist = loc.getZ($middleloc) - loc.getZ(ent_loc);
- distance = math.sqrt(math.pow(x_dist, 2) + math.pow(y_dist, 2) + math.pow(z_dist, 2));
-
- return distance;
- }
- function Snow.aimassist(player){
- //creates particle effect of where a snowball would fly
- motion = entity.getLook(player);
- location = entity.getLocation(player);
- loc.addY(location, 1.5);
- for (i = 0; i < 50; i++){
- add_motion = Snow.get_acc(location);
- for (j = 0; j < 3; j++){
- motion[j] += add_motion[j];
- }
- //current_block = block.get(location);
- //Material = block.getType(current_block);
- //if (Material != $Air){
- //snuvi.debug(Material);
- // break;
- //}
- loc.add(location, 4*motion[0], 4*motion[1], 4*motion[2]);
- particle.spawnPlayer(location, $snow_particle, player, 0, 0 ,0);
- }
- }
- function gravitors_loc(){
- //returns the locations of the gravitor list
- grav_locs = list.new();
- list_iterator = iterator($gravitors);
- while(hasnext(list_iterator)){
- gravitor = next(list_iterator);
- gravitor_loc = entity.getLocation(gravitor);
- list.add(grav_locs, gravitor_loc);
- }
- return grav_locs;
- }
- function Snow.get_acc(location){
- //returns the accelleration of an object given the black/white holes in a map
- accvector1 = Snow.acc(location, $black_holes);
- accvector2 = Snow.acc(location, $white_holes);
- //accvector3 = Snow.acc(location, $grav_locs);
- //snuvi.debug($black_holes);
-
- accvector = array.new(3);
- for (i = 0; i<3; i++){
- accvector[i] = accvector1[i]-accvector2[i];// + 0.01*accvector3[i];
- }
- return accvector;
- }
- function Snow.acc(location, list){
- //returns the accelleration of an object given by the objects in the list
- G = 5;
- accvector = array.new(3);
- accvector[0] = 0;
- accvector[1] = 0;
- accvector[2] = 0;
-
- loc_X = loc.getX(location);
- loc_Y = loc.getY(location);
- loc_Z = loc.getZ(location);
-
- list_iterator = iterator(list);
- while(hasnext(list_iterator)){
- hole_loc = next(list_iterator);
-
- x_dist = loc.getX(hole_loc) - loc_X;
- y_dist = loc.getY(hole_loc) - loc_Y;
- z_dist = loc.getZ(hole_loc) - loc_Z;
- distance = math.sqrt(math.pow(x_dist, 2) + math.pow(y_dist, 2) + math.pow(z_dist, 2));
- if (distance > 50 || distance < 0.1){
- continue;
- }
- dist_sqrt = math.pow(distance,2);
- accvector[0] += x_dist/dist_sqrt;
- accvector[1] += y_dist/dist_sqrt;
- accvector[2] += z_dist/dist_sqrt;
- }
- for (i = 0; i<3; i++){
- accvector[i] *= G;
- }
- return accvector;
- }
- function Snow.change_polarity(){
- //changes black to white holes and the other way round
- temp_list = list.new();
- temp_list = $black_holes;
- $black_holes = $white_holes;
- $white_holes = $black_holes;
- }
- function Snow.gravitate(entity_){
- //sets the Motion of an entity to gravitate towards black holes and away from white holes
- ent_loc = entity.getLocation(entity_);
- accvector = Snow.get_acc(ent_loc);
- motion = entity.getMotion(entity_);
- x = motion[0];
- y = motion[1];
- z = motion[2];
-
- entity.setMotion(entity_, x + accvector[0], y + accvector[1], z + accvector[2]);
- }
- function colorgameover(team) {
- tempcolortext = map.get($teamcolortext, team);
- minigame.speakAll($gamename, string.concat("§cThe ", tempcolortext, " §cTeam has been eliminated."));
- list.remove($allteams, team);
- if(list.getSize($allteams) == 1) {
- $endtime = time.getMillis();
- kickteam(team, true, false);
- win_team = list.getIndex($allteams, 0);
- kickteam(win_team, true, true);
- minigame.clearItems($middleloc, $radius);
- script = script.getFromId($script_id);
- minigame.term(script, $gamesignloc);
- term();
- }
- kickteam(team, false, false);
- }
- function kickteam(team, show_time, won) {
- teamlist = map.get($team_lists, team);
- for(i = 0; i < list.getSize(teamlist); i++) {
- p_name = list.getIndex(teamlist, i);
- p = read.player(p_name);
- showstats(p, show_time, won);
- script = script.getFromId($script_id);
- minigame.kickplayer(script, p);
- if(won) {
- //money.addBoost(p, 128);
- } else {
- //money.addBoost(p, 32);
- }
- }
- }
- function showstats(player, show_time, won) { //Player player, Boolean show_time, Boolean won
- player_name = player.getName(player);
- player_id = player.getId(player);
- last_record = ranking.getPoints($rankingtable, player_id);
- playedgames = minigame.getPlayed(player_id, $game_short) + 1;
- minigame.setPlayed(player_id, $game_short, playedgames);
- kills = map.get($kills_map, player_name);
- record = last_record + kills;
- ranking.setPoints($rankingtable, player_id, record);
- deaths = map.get($deaths_map, player_name);
- wongames = minigame.getWon(player, $game_short);
- if(won) {
- wongames++;
- minigame.setWon(player, $game_short, wongames);
- }
-
- minigame.statsHeader(player, $gamename, "§e");
- if(show_time) {
- time = ($endtime - $starttime) / 1000;
- minigame.statsLine(player, "§e", "Time", string.concat(string.number(math.rounddown(time / 60)), " min ", string.number(math.round(time % 60)), " s"));
- }
- minigame.statsLine(player, "§e", "Kills", string.number(kills));
- minigame.statsLine(player, "§e", "Deaths", string.number(deaths));
- if(deaths != 0) {
- kd = kills / deaths;
- minigame.statsLine(player, "§e", "K/D", string.number(math.roundcomma(kd, 2)));
- }
- minigame.statsLine(player, "§e", "Won games", string.number(wongames));
- minigame.statsLine(player, "§e", "Played games", string.number(playedgames));
- if(playedgames != 0) {
- minigame.statsLine(player, "§e", "Win ratio", string.concat(string.number(math.roundComma((wongames / playedgames) * 100, 2)), "%"));
- }
- }
- function giveSnowballs(player) {
- player.giveItem(player, $snow_stack);
- player.giveItem(player, $snow_stack);
- player.giveItem(player, $snow_stack);
- player.giveItem(player, $snow_stack);
- player.giveItem(player, $snow_stack);
- player.giveItem(player, $snow_stack);
- player.giveItem(player, $snow_stack);
- player.giveItem(player, $snow_stack);
- player.giveItem(player, $snow_stack);
- }
- function equipPlayer(player, team) {
- if(living.getEquip(player, slot.getHead()) == null) {
- color = map.get($cloth_color, team);
- living.setEquip(player, slot.getHead(), read.item(string.concat("{id:'minecraft:leather_helmet',Count:1b,tag:{display:{color:", color, "}}}")));
- living.setEquip(player, slot.getChest(), read.item(string.concat("{id:'minecraft:leather_chestplate',Count:1b,tag:{display:{color:", color, "}}}")));
- living.setEquip(player, slot.getLegs(), read.item(string.concat("{id:'minecraft:leather_leggings',Count:1b,tag:{display:{color:", color, "}}}")));
- living.setEquip(player, slot.getFeet(), read.item(string.concat("{id:'minecraft:leather_boots',Count:1b,tag:{display:{color:", color, "}}}")));
- }
- }
- function minigame.canStartIndiv() {
- player_list = minigame.getPlayers($script_id);
- p_amount = list.getSize(player_list);
- if(p_amount < minigame.getMinPlayers()) {
- return false;
- }
- if(p_amount > 0 && list.getSize($waiters) > 0) {
- return true;
- }
- for(i = 0; i < $numberofteams; i++) {
- teamlist = map.get($team_lists, i);
- team_size = list.getSize(teamlist);
- if(team_size == p_amount) {
- return false;
- }
- }
- return true;
- }
|