123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463 |
- //Hier werden alle Events abgefangen und beeinflusst, je nachdem ob ein Skill aktiv ist oder nicht
- //event.load("projectile_hit");
- event.load("living_death");
- event.load("block_break");
- //event.load("player_data_tick");
- event.load("snuvi_click");
- event.load("block_click");
- prefix_skill = "§2Skill";
- scroll_menu_item = customitem.create("SCROLL", 1, "§2Skills", null);
- setScriptVar("skills", list.new());
- //skill.add(skill_name, tech_name, item, description, cost, permanent, active, toggleable, cooldown, mana, time)
- skill.add("Keep Inventory", "skill.subcu_inv", "minecraft:chest", "Keeps the inventory on death", 10, false, false, true, 0, 0, null);
- skill.add("Comeback", "skill.comeback", "minecraft:respawn_anchor", "Respawn at your death location with /comeback", 15, false, false, false, 0, 0, null);
- skill.add("Better_Ladder", "skill.bet_lad", "minecraft:ladder", "Allows to elongate ladders below or above oneself when sneaking", 2048, true, false, true, 0, 0, null);
- //skill.add("Head Hunter", "skill.head_human", "minecraft:player_head", "Drops a player's head with a 20% chance if you kill a player (5% if a staff member is killed)", 1000, true, false, false, 0, 0, null);
- //skill.add("Mobheads", "skill.head_monster", "minecraft:zombie_head", "Drops a mobs's head with a 20% chance (zombie / skeleton / creeper)", 500, true, false, false, 0, 0, null);
- //skill.add("Fly 10min", "skill.fly10min", "minecraft:elytra", "You can fly for 10 minutes", 500, false, true, false, 0, 0, 600);
- //skill.add("Grow", "skill.grow", "minecraft:farmland", "Grow seeds in radius 5", 25, false, true, false, 0, 0, null);
- //skill.add("Haste", "skill.haste", "minecraft:iron_pickaxe", "Haste for 2 minutes", 25, false, true, false, 0, 0, 120);
- //skill.add("Speed", "skill.speed", "minecraft:iron_boots", "Speed for 2 minutes", 25, false, true, false, 0, 0, 120);
- //skill.add("Jump Boost", "skill.jump_boost", "minecraft:rabbit_foot", "JumpBoost Lvl.2 for 2 minutes", 25, false, true, false, 0, 0, 120);
- //skill.add("Dolphin", "skill.dolphin", "minecraft:fire_coral", "Swim like a dolphin for a minute", 25, false, true, false, 0, 0, 60);
- //skill.add("Block Up", "skill.block_up", "minecraft:diamond_pickaxe", "Break a block and the block above for a minute", 25, false, true, false, 0, 0, 60);
- //skill.add("Block Down", "skill.block_down", "minecraft:diamond_pickaxe", "Break a block and the block below for a minute", 25, false, true, false, 0, 0, 60);
- skill.add("Timber", "skill.timber", "minecraft:iron_axe", "Break whole trees with an axe", 4096, true, false, true, 0, 0, null);
- //skill.add("Fire Arrow", "skill.fire_arrow", "minecraft:arrow", "For a minute with an flame enchanted bow your arrows ignite hit blocks", 50, false, true, false, 0, 0, 60);
- //skill.add("Better Shears", "skill.better_shears", "minecraft:shears", "Sharpness enchanted shears increase the radius for destruction of leaves", 1024, true, false, true, 0, 0, null);
- //skill.add("Cobweb Miner", "skill.cobweb_miner", "minecraft:cobweb", "Swords increase the radius for destruction of cobwebs", 250, true, false, true, 0, 0, null);
- death_loc_map = map.new();
- leaves_tag = block.getTag("minecraft:leaves");
- //prop_persistent = block.getProperty("persistent");
- air_mat = material.get("AIR");
- water_mat = material.get("WATER");
- ladder_mat = material.get("LADDER");
- msg("dev", text.new("§bSkills §rloaded."));
- @wait
- wait();
- //Wenn Event aus Survival-Welten, dann wird er verarbeitet
- if(event == "living_death") {
- loc = entity.getLocation(living_entity);
- } else {
- loc = entity.getLocation(player);
- }
- world_name = world.getName(loc.getWorld(loc));
- if(world.isSurvName(world_name)) {
- ignoreGoto(event);
- }
- goto("wait");
- @snuvi_click
- item = inv.getItem(inv, inv_slot);
- item.removeFlag(item, "HIDE_DESTROYS");
- title_string = string.text(inv_title);
- if(item == scroll_menu_item) {
- if(title_string == "Lumberjack") {
- if(!player.unlockedLumberjack(player)) {
- msg.prefix(player, prefix_skill, "Skillshop is locked. Do a quest first.");
- goto("wait");
- }
- skill.showShop(player, "skill.timber", "skill.bet_lad", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
- goto("wait");
- }
- if(title_string == "Mage") {
- if(!player.unlockedMage(player)) {
- msg.prefix(player, prefix_skill, "Skillshop is locked. Do the 'Mage' quest at the 'Mage Guard' first.");
- goto("wait");
- }
- skill.showShop(player, "skill.subcu_inv", "skill.comeback", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
- //skill.showShop(player, "skill.subcu_inv", "skill.comeback", "skill.head_human", "skill.head_monster", "skill.fly10min", "skill.grow", "skill.haste", "skill.speed", "skill.jump_boost", "skill.dolphin", "skill.block_up", "skill.block_down", "skill.fire_arrow", "skill.cobweb_miner", null, null, null, null);
- }
- goto("wait");
- }
- if(title_string == "Skillshop") {
- if(item == null) {
- goto("wait");
- }
- skill_name = string.removeFormat(string.text(item.getName(item)));
- if(skill_name == "") {
- goto("wait");
- }
- tech_name = skill.getTechName(skill_name);
- if(skill.isPermanent(tech_name)) {
- amount = skill.getAmount(player, tech_name);
- if(amount >= 1) {
- goto("wait");
- }
- }
- cost = skill.getCost(tech_name);
- if(!hasEnoughMoney(player, cost)) {
- msg.prefix(player, prefix_skill, "Not enough snuvis.");
- goto("wait");
- }
- money.sub(player, cost);
- skill.addAmount(player, tech_name, 1);
- inv.setItem(inv, inv_slot, skill.getShopItem(player, tech_name));
- }
- goto("wait");
- @player_data_tick
- if(var == "fly") {
- tpBottom(player);
- player.setFly(player, false);
- msg.prefix(player, prefix_skill, "Fly time is over.");
- }
- goto("wait");
- @projectile_hit
- if(!isPlayer(shooter)) {
- goto("wait");
- }
- player = shooter;
- duration = data.getTimer(player, "skill.fire_arrow");
- if(duration > 0) {
- if(loc_hit == null) {
- goto("wait");
- }
- flame = enchantment.getLevel(ench_flame, living.getHand(player));
- if(flame <= 0) {
- goto("wait");
- }
- if(!plot.check(loc_hit, player, 3, true) && !perm.has(player, "plot.bypass")) {
- msg.prefix(player, prefix_skill, "You have no permissions on this plot.");
- goto("wait");
- }
- ent_loc = entity.getLocation(projectile);
- if(block.isAir(ent_loc)){
- block.set(ent_loc, "minecraft:fire");
- }
- fire_ring(ent_loc, "minecraft:fire", 0);
- }
- goto("wait");
- @living_death
- if(isPlayer(living_entity)) {
- player = living_entity;
- loc = entity.getLocation(player);
- amount = skill.getAmount(player, "skill.subcu_inv");
- if(skill.isActivated(player, "skill.subcu_inv") && amount > 0) {
- new_amount = amount - 1;
- skill.setAmount(player, "skill.subcu_inv", new_amount);
- msg.prefix(player, prefix_skill, string.concat("Used Subcutaneous Inventory. New amount: ", string.number(new_amount)));
- } else {
- player.dropInventory(player, loc);
- }
- killer = player.getFromDamageSource(damage_source);
- if(isPlayer(killer)) {
- amount = skill.getAmount(player, "skill.head_human");
- if(amount >= 1) {
- if(perm.has(player, "isTeam")) {
- temp = math.random(1, 20);
- } else {
- temp = math.random(1, 5);
- }
- if(temp == 1) {
- item.drop(loc, player.getHead(player.getUuid(player), player.getName(player)));
- }
- }
- }
- goto("wait");
- }
- killer = player.getFromDamageSource(damage_source);
- if(isPlayer(killer)) {
- r = math.random(1, 20);
- if(r == 1) {
- amount = skill.getAmount(killer, "skill.head_monster");
- if(amount >= 1) {
- entity_type = entity.getType(living_entity);
- if(entity_type == "creeper") {
- item.drop(loc, read.item("minecraft:creeper_head"));
- goto("wait");
- }
- if(entity_type == "zombie") {
- item.drop(loc, read.item("minecraft:zombie_head"));
- goto("wait");
- }
- if(entity_type == "skeleton") {
- item.drop(loc, read.item("minecraft:skeleton_skull"));
- goto("wait");
- }
- }
- }
- }
- goto("wait");
- @block_break
- goto("wait");
- duration = data.getTimer(player, "block_down");
- if(duration > 0) {
- do = true;
- loc = loc.mod(block_loc, 0, -1, 0);
- b_type = block.getType(loc);
- if(b_type == "minecraft:bedrock" || b_type == "minecraft:end_portal_frame") {
- do = false;
- }
- if(!plot.check(loc, player, 2, true)) {
- do = false;
- }
- if(do) {
- block.break(loc, player);
- }
- }
- duration = data.getTimer(player, "block_up");
- if(duration > 0) {
- do = true;
- loc = loc.mod(block_loc, 0, 1, 0);
- b_type = block.getType(loc);
- if(b_type == "minecraft:bedrock" || b_type == "minecraft:end_portal_frame") {
- do = false;
- }
- if(!plot.check(loc, player, 2, true)) {
- do = false;
- }
- if(do) {
- block.break(loc, player);
- }
- }
- if(block_type == "minecraft:cobweb") {
- if(cancel) {
- goto("wait");
- }
- hand_item = living.getHand(player);
- if(!item.hasTag(hand_item, sword_tag)) { //TODO sword_tag (km:sword) no longer exists
- goto("wait");
- }
- amount = skill.getAmount(player, "skill.cobweb_miner");
- if(amount <= 0) {
- goto("wait");
- }
- if(!skill.isActivated(player, "skill.cobweb_miner")) {
- goto("wait");
- }
- location = loc.mod(block_loc, 0, 0, 0);
- cobweb_X = loc.getX(location);
- cobweb_Y = loc.getY(location);
- cobweb_Z = loc.getZ(location);
- cobweb_radius = 1;
- unbreaking_level = enchantment.getLevel(ench_unbreaking, hand_item);
- for(a = -cobweb_radius; a < cobweb_radius + 1; a++) {
- loc.setX(location, cobweb_X + a);
- for(b = -cobweb_radius; b < cobweb_radius + 1; b++) {
- loc.setY(location, cobweb_Y + b);
- for(c = -cobweb_radius; c < cobweb_radius + 1; c++) {
- loc.setZ(location, cobweb_Z + c);
- if(math.abs(a) + math.abs(b) + math.abs(c) + math.random(0, 2) < cobweb_radius + 2) {
- shear_cobweb(location, block_type, player, unbreaking_level);
- }
- }
- }
- }
- goto("wait");
- }
- if(block.isLeaves(block)) {
- if(cancel) {
- goto("wait");
- }
- hand_item = living.getHand(player);
- if(item.getType(hand_item) != "minecraft:shears") {
- goto("wait");
- }
- if(block.property.getValue(block_loc, prop_persistent)){
- goto("wait");
- }
- amount = skill.getAmount(player, "skill.better_shears");
- if(amount <= 0) {
- goto("wait");
- }
- if(!skill.isActivated(player, "skill.better_shears")) {
- goto("wait");
- }
- location = loc.mod(block_loc, 0, 0, 0);
- shears_X = loc.getX(location);
- shears_Y = loc.getY(location);
- shears_Z = loc.getZ(location);
- unbreaking_level = enchantment.getLevel(ench_unbreaking, hand_item);
- radius = enchantment.getLevel(ench_sharpness, hand_item);
- if(radius > 0) {
- cancel = true;
- }
- orig_item = block.toStack(location);
- for(a = -radius; a < radius + 1; a++){
- loc.setX(location, shears_X + a);
- for(b = -radius; b < radius + 1; b++){
- loc.setY(location, shears_Y + b);
- for(c = -radius; c < radius + 1; c++){
- loc.setZ(location, shears_Z + c);
- if(math.abs(a) + math.abs(b) + math.abs(c) + math.random(0, 2) < radius + 2) {
- shear_leave(location, block_type, orig_item, player, unbreaking_level);
- }
- }
- }
- }
- goto("wait");
- }
- goto("wait");
- @block_click
- if(skill.isActivated(player, "skill.bet_lad")){
- if (!player.isSneaking(player)){
- goto("wait");
- }
- if (action != "RIGHT_CLICK_BLOCK"){
- goto("wait");
- }
- mat = block.getType(block);
- item_mat = item.getType(living.getEquip(player, hand));
-
- if (mat != air_mat){
- if(item_mat != mat){
- goto("wait");
- }
- }
-
- look = entity.getLook(player);
-
- if(mat == ladder_mat){
- xyz = better_ladder.vertical_split(look);
- }
- elseif(false){//elseif(mat == chain_mat){
- if (!string.contains(string.blockData(block.getData(block)), "axis=y")){
- goto("wait");
- }
- //xyz = vertical_split(look);
- xyz = array.new(3);
- xyz[0] = 0;
- xyz[1] = -1;
- xyz[2] = 0;
- }
- elseif(false){//elseif(mat == rail_mat){
- xyz = better_ladder.horizontal_split(player);
- }
- elseif(false){//elseif(mat == vines_mat){
- xyz = array.new(3);
- xyz[0] = 0;
- xyz[1] = -1;
- xyz[2] = 0;
- }
- else{
- goto("wait");
- }
-
- better_ladder.continue_block(player, block, mat, xyz);
- cancel = true;
- }
- goto("wait");
- function shear_leave(block_loc, original_block_type, original_item, player, unbreaking_level){
- if(block.getType(block_loc) != original_block_type) {
- return;
- }
- if(block.property.getValue(block_loc, $prop_persistent)) {
- return;
- }
- block.set(block_loc, "minecraft:air");
- item.drop(block_loc, original_item);
- if(player.isSurvival(player)) {
- player.damageItem(player, 1);
- }
- }
- function shear_cobweb(block_loc, original_block_type, player, unbreaking_level) {
- if(block.getType(block_loc) != original_block_type) {
- return;
- }
- block.break(block_loc, player);
- if(math.random(0, 99) < 100 / (unbreaking_level + 1)) {
- player.damageItem(player, 1);
- }
- }
- function better_ladder.vertical_split(look){
- xyz = array.new(3);
- for (i = 0; i<3; i++){
- xyz[i] = 0;
- }
- if (look[1] > 0){
- xyz[1] = 1;
- }
- else{
- xyz[1] = -1;
- }
- return xyz;
- }
- function better_ladder.horizontal_split(player){
- xyz = array.new(3);
-
- for (i = 0; i<3; i++){
- xyz[i] = 0;
- }
-
- loc = entity.getLocation(player);
- yaw = loc.getYaw(loc);
-
- if (yaw < -135){
- xyz[2] = -1;
- }
- elseif (yaw < -45){
- xyz[0] = 1;
- }
- elseif (yaw < 45){
- xyz[2] = 1;
- }
- elseif (yaw < 135){
- xyz[0] = -1;
- }
- else{
- xyz[2] = -1;
- }
- return xyz;
- }
- function better_ladder.continue_block(player, block, of_mat, xyz){
- itemstack = item.new(of_mat, 1);
- b_loc = block.getLocation(block);
- set_water_logged = false;
- i = 0;
- while(true){
- loc.add(b_loc, xyz[0], xyz[1], xyz[2]);
- new_block = block.get(b_loc);
- if (!plot.check(b_loc, player, 23, true) || i >= 5){
- return;
- }
- mat = block.getType(new_block);
- if(mat == $air_mat){
- break;
- }
- elseif(mat == $water_mat){
- msg.dev(block.getData(new_block));
- if (string.contains(string.blockData(block.getData(new_block)), "falling=true")){
- break;
- }
- elseif(!string.contains(string.blockData(block.getData(new_block)), "level=0")){
- break;
- }
- elseif (block.canHaveWater(block)){
- set_water_logged = true;
- break;
- }
- else{
- return;
- }
- }
- elseif (mat != of_mat){
- return;
- }
- i += 1;
- }
- block.clone(block, b_loc, true);
- if (block.canHaveWater(block)){
- block.setWaterLogged(new_block, set_water_logged);
- }
- if (player.isSurvival(player)){
- player.removeItem(player, itemstack);
- }
- }
|