Browse Source

new skills and skillshop

mloeschenkohl 3 years ago
parent
commit
e5083fd91a

+ 0 - 0
dev/FireArrow.txt → Archiv/jan/FireArrow.txt


+ 0 - 0
dev/cobweb_test.txt → Archiv/jan/cobweb_test.txt


+ 0 - 0
dev/shears_test.txt → Archiv/jan/shears_test.txt


+ 13 - 3
story/admont/core.txt

@@ -1,9 +1,11 @@
 event.load("human_hurt");
 event.load("entity_click");
 event.load("inv_click");
+event.load("skill_showshop");
 
-timestamp = map.new(); //TimeStamp for SkillShop
+timestamp = map.new(); //TimeStamp for Felsmagier-SkillShop
 stable_loc = loc.new(world.getStory(), -1584, 66, -57);
+prefix_skill = "§2Skill";
 
 msg("dev", "§bQuests: §rAdmont loaded.");
 @wait
@@ -55,7 +57,7 @@ if(entity_name == "Zauberlehrling") {
 }
 if(entity_name == "Felsmagier") {
 	if(time.getMillis() - map.getOrDefault(timestamp, player.getUuid(player), 0) < 120000) { //2 Minutes
-		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.timber", 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);
 	} else {
 		msg.prefix(player, "§dFelsmagier", "Du musst zuerst ein paar Aufgaben für mich erledigen. Finde meinen Zauberlehrling, der hilft dir weiter.");
 	}
@@ -310,7 +312,7 @@ if(inv_name == "Skillshop") {
 	}
 	cost = skill.getCost(skill_name);
 	if(!hasEnoughMoney(player, cost)) {
-		msg.prefix(player, "§dFelsmagier", "Du hast nicht genug Snuvis.");
+		msg.prefix(player, prefix_skill, "Du hast nicht genug Snuvis.");
 		goto("wait");
 	}
 	subMoney(player, cost);
@@ -320,6 +322,14 @@ if(inv_name == "Skillshop") {
 }
 goto("wait");
 
+@skill_showshop
+player = getScriptVar("player");
+shop_type = getScriptVar("shop_type");
+if(shop_type == "foerster") {
+	skill.showShop(player, "skill.timber", "skill.better_shears", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
+}
+goto("wait");
+
 function checkAdmontStable() {
 	list = living.near($stable_loc, 30);
 	size = list.getSize(list);

+ 2 - 1
story/admont/ich_und_mein_holz.txt

@@ -48,11 +48,12 @@ goto("wait");
 if(event == "entity_click" && hand == "MAIN_HAND" && entity.getType(entity) == "human") {
 	entity_name = entity.getName(entity);
 	if(entity_name == "Förster") {
-		rest_amount = human.giveItem("Förster", player, "minecraft:spruce_log", spruce_log);
+		rest_amount = human.giveItem("Förster", player, "minecraft:spruce_log", 1);
 		if(rest_amount == 0) {
 			msg.prefix(player, "§dFörster", "Danke, ich werde es zur Verarbeitung weiterreichen");
 			money.addBoost(player, 8);
 			msg(player, "§dQuest abgeschlossen. Belohnung: 8 Snuvis!");
+			quest.callShowShop(player, "foerster");
 			quest.finish(script, player);
 		} else {
 			spruce_log = rest_amount;

+ 18 - 2
system/commands.txt

@@ -724,7 +724,7 @@ if(event == "inv_click") {
 		}
 		skill_name = removeFormat(item.getName(item));
 		tech_name = skill.getTechName(skill_name);
-		//Toggle skill
+		//Toggle skills
 		if(skill.isToggleable(skill_name)) {
 			if(skill.isActivated(player, tech_name)) {
 				skill.setActivated(player, tech_name, false);
@@ -743,6 +743,22 @@ if(event == "inv_click") {
 				msg.prefix(player, prefix_skill, "You can't use this in this world.");
 				goto("wait");
 			}
+			if(tech_name == "skill.fire_arrow") {
+				duration = data.getTimer(player, tech_name);
+				if(duration > 0) {
+					msg.prefix(player, prefix_skill, "Skill already active.");
+					goto("wait");
+				}
+				amount = skill.getAmount(player, tech_name);
+				if(amount > 0) {
+					status.addTimed(player, 54, 1200, skill_name);
+					data.setTimer(player, tech_name, 1200);
+					new_amount = amount - 1;
+					skill.setAmount(player, tech_name, new_amount);
+					msg.prefix(player, prefix_skill, concat("Used ", skill_name, ". New amount: ", text.number(new_amount)));
+				}
+				goto("wait");
+			}
 			if(tech_name == "skill.timber") {
 				duration = data.getTimer(player, "timber");
 				if(duration > 0) {
@@ -751,7 +767,7 @@ if(event == "inv_click") {
 				}
 				amount = skill.getAmount(player, "skill.timber");
 				if(amount > 0) {
-					status.addTimed(player, 50, 1200, "Timber");
+					status.addTimed(player, 53, 1200, "Timber");
 					data.setTimer(player, "timber", 1200);
 					new_amount = amount - 1;
 					skill.setAmount(player, "skill.timber", new_amount);

+ 158 - 2
system/survival.txt

@@ -12,6 +12,7 @@ event.load("player_toss");
 event.load("pre_explosion");
 event.load("mob_griefing");
 event.load("item_air_click");
+event.load("projectile_hit");
 
 setScriptVar("skills", list.new());
 skill.add("Keep Inventory", "skill.subcu_inv", "minecraft:chest", "Keeps the inventory on death", 100, false, false, true);
@@ -27,6 +28,9 @@ skill.add("Dolphin", "skill.dolphin", "minecraft:fire_coral", "Swim like a dolph
 skill.add("Block Up", "skill.block_up", "minecraft:diamond_pickaxe", "Break a block and the block above for a minute", 25, false, true, false);
 skill.add("Block Down", "skill.block_down", "minecraft:diamond_pickaxe", "Break a block and the block below for a minute", 25, false, true, false);
 skill.add("Timber", "skill.timber", "minecraft:iron_axe", "Break whole trees with an axe for a minute", 128, false, true, false);
+skill.add("Fire Arrow", "skill.fire_arrow", "minecraft:arrow", "For a minute with an flame enchanted bow your arrows ignites hitten blocks", 50, false, true, false);
+skill.add("Better Shears", "skill.better_shears", "minecraft:shears", "Sharpness enchanted shears increases the radius for destruction of leaves", 500, true, false, true);
+skill.add("Cobweb Miner", "skill.cobweb_miner", "minecraft:cobweb", "Swords increases the radius for destruction of cobwebs", 250, true, false, true);
 
 clan.loadData();
 
@@ -111,8 +115,11 @@ grass = "minecraft:grass";
 iron_nugget = "minecraft:iron_nugget";
 hay_bundle = "km:hay_bundle";
 real_hay_block = "km:real_hay_block";
+sword_tag = item.getTag("km:sword");
 dye_tag = item.getTag("km:dye");
+leaves_tag = block.getTag("minecraft:leaves");
 sign_tag = block.getTag("minecraft:signs");
+prop_persistent = block.getProperty("persistent");
 
 recipe.add(1, "minecraft:saddle", leather, leather, leather, leather, string, leather, air, iron_ingot, air);
 recipe.add(1, "km:bronze_helmet", bronze_ingot, bronze_ingot, bronze_ingot, bronze_ingot, air, bronze_ingot, air, air, air);
@@ -205,6 +212,9 @@ recipe.add(1, "km:lantern", iron_nugget, iron_nugget, iron_nugget, "minecraft:gl
 recipe.add(1, "km:sling", stick, string, stick, stick, air, stick, air, stick, air);
 recipe.add(4, "minecraft:string", air, air, air, air, "minecraft:white_wool", air, air, air, air);
 
+ench_flame = enchantment.get("flame");
+ench_unbreaking = enchantment.get("unbreaking");
+ench_sharpness = enchantment.get("sharpness");
 par = particle.get("minecraft:witch");
 piston_sound = sound.get("block.piston.extend");
 adv_tp_sound = sound.get("block.portal.travel");
@@ -619,6 +629,50 @@ if(inv_name == "Recipes") {
 }
 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");
+
+function fire_ring(location, block_string, radius){
+	loc_x = loc.getX(location);
+	loc_y = loc.getY(location);
+	loc_z = loc.getZ(location);
+	for(a = -radius; a < radius + 1; a++){
+		loc.setX(location, loc_x + a);
+		for(b = -radius; b < radius + 1; b++){
+			loc.setY(location, loc_y + b);
+			for(c = -radius; c < radius + 1; c++){
+				loc.setZ(location, loc_z + c);
+				if(block.isAir(location)){
+					block.set(location, block_string);
+				}
+			}
+		}
+	}
+}
+
 @block_break
 duration = data.getTimer(player, "block_down");
 if(duration > 0) {
@@ -650,8 +704,110 @@ if(duration > 0) {
 		block.break(loc, player);
 	}
 }
+if(block_type == "minecraft:cobweb") {
+	if(cancel) {
+		goto("wait");
+	}
+	hand_item = living.getHand(player);
+	if(!item.hasTag(sword_tag, hand_item)) {
+		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);
+	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.hasTag(leaves_tag, 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");
 
+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)) {
+		if(math.random(0, 99) < 100 / (unbreaking_level + 1)) {
+			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);
+	}	
+}
+
 @block_click
 if(action == "right" && player.checkHandsForTag(player, dye_tag)) {
 	if(block.hasTag(sign_tag, block)) {
@@ -1210,7 +1366,7 @@ function lottery.set(location, amount) {
 	text_entity = list.getIndex(list, 0);
 	name = entity.getName(text_entity);
 	if(!text.startsWith(name, "Snuvis: ", 0)) {
-		msg("dev", "Lottery error");
+		snuvi.debug("Lottery error");
 		goto("wait");
 	}
 	entity.setName(text_entity, concat("Snuvis: ", text.number(amount)), true);
@@ -1222,7 +1378,7 @@ function lottery.add(location, amount) {
 	text_entity = list.getIndex(list, 0);
 	name = entity.getName(text_entity);
 	if(!text.startsWith(name, "Snuvis: ", 0)) {
-		msg("dev", "Lottery error");
+		snuvi.debug("Lottery error");
 		goto("wait");
 	}
 	amount = text.convert(text.subString(name, 8, text.length(name))) + 1;

+ 12 - 5
utils/u_general.txt

@@ -649,11 +649,11 @@ function quest.addCounter(player, amount) {
 }
 
 function quest.finish(script, player) {
-	quest.addCounter(player, 1);
-	quest.term(script, player);
 	sound = sound.get("entity.experience_orb.pickup");
 	category = sound.getCategory("master");
 	sound.spawnForPlayer(player, sound, category);
+	quest.addCounter(player, 1);
+	quest.term(script, player);
 }
 
 function quest.term(script, player) {
@@ -2165,13 +2165,16 @@ function player.isCommandBlocked(player) {
 	return list.contains(list, player.getUuid(player));
 }
 
-function player.checkHandsForItem(player, item) {
+function player.checkHandsForItem(player, item_or_type) {
+	if(text.class(item_or_type) != "String") {
+		item_or_type = item.getType(item_or_type);
+	}
 	hand = living.getEquip(player, "hand");
-	if(item.getType(hand) == item.getType(item)) {
+	if(item.getType(hand) == item_or_type) {
 		return true;
 	}
 	offhand = living.getEquip(player, "offhand");
-	return item.getType(offhand) == item.getType(item);
+	return item.getType(offhand) == item_or_type;
 }
 
 function player.checkHandsForTag(player, tag) {
@@ -3083,6 +3086,10 @@ function living.getAi() {
 	return config.getBool(config, "spawnWithAi", true);
 }
 
+function living.getHand(living) {
+	return living.getEquip(living, "hand");
+}
+
 //--------------------------------------------------
 //Afk-Utils
 //--------------------------------------------------

+ 6 - 0
utils/u_quest.txt

@@ -77,4 +77,10 @@ function human.giveItem(human_name, player, needed_type_or_tag, needed_amount) {
 	}
 	msg.prefix(player, human_name, "Das kann ich nicht gebrauchen.");
 	return needed_amount;
+}
+
+function quest.callShowShop(player, shop_type) {
+	setScriptVar("player", player);
+	setScriptVar("shop_type", shop_type);
+	script.callEvent("skill_showshop");
 }