skills.txt 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. //Hier werden alle Events abgefangen und beeinflusst, je nachdem ob ein Skill aktiv ist oder nicht
  2. event.load("projectile_hit");
  3. event.load("living_death");
  4. event.load("block_break");
  5. event.load("player_post_respawn");
  6. prefix_skill = "§2Skill";
  7. setScriptVar("skills", list.new());
  8. skill.add("Keep Inventory", "skill.subcu_inv", "minecraft:chest", "Keeps the inventory on death", 100, false, false, true, 0, 0, null);
  9. skill.add("Comeback", "skill.comeback", "km:skill55", "Respawn at your death location", 100, false, false, true, 0, 0, null);
  10. 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);
  11. 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);
  12. skill.add("Fly 10min", "skill.fly10min", "minecraft:elytra", "You can fly for 10 minutes", 500, false, true, false, 0, 0, 600);
  13. skill.add("Grow", "skill.grow", "minecraft:farmland", "Grow seeds in radius 5", 25, false, true, false, 0, 0, null);
  14. skill.add("Haste", "skill.haste", "minecraft:iron_pickaxe", "Haste for 2 minutes", 25, false, true, false, 0, 0, 120);
  15. skill.add("Speed", "skill.speed", "minecraft:iron_boots", "Speed for 2 minutes", 25, false, true, false, 0, 0, 120);
  16. skill.add("Jump Boost", "skill.jump_boost", "minecraft:rabbit_foot", "JumpBoost Lvl.2 for 2 minutes", 25, false, true, false, 0, 0, 120);
  17. skill.add("Dolphin", "skill.dolphin", "minecraft:fire_coral", "Swim like a dolphin for a minute", 25, false, true, false, 0, 0, 60);
  18. 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);
  19. 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);
  20. skill.add("Timber", "skill.timber", "minecraft:iron_axe", "Break whole trees with an axe for a minute", 128, false, true, false, 0, 0, 60);
  21. 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);
  22. skill.add("Better Shears", "skill.better_shears", "minecraft:shears", "Sharpness enchanted shears increase the radius for destruction of leaves", 500, true, false, true, 0, 0, null);
  23. skill.add("Cobweb Miner", "skill.cobweb_miner", "minecraft:cobweb", "Swords increase the radius for destruction of cobwebs", 250, true, false, true, 0, 0, null);
  24. msg("dev", "§bSurvival §rloaded.");
  25. @wait
  26. wait();
  27. //Wenn Event aus Survival-Welten, dann wird er verarbeitet
  28. if(event == "living_death") {
  29. loc = entity.getLocation(living_entity);
  30. } else {
  31. loc = entity.getLocation(player);
  32. }
  33. world_name = world.getName(loc.getWorld(loc));
  34. if(world.isSurvName(world_name)) {
  35. ignoreGoto(event);
  36. }
  37. goto("wait");
  38. @projectile_hit
  39. if(!isPlayer(shooter)) {
  40. goto("wait");
  41. }
  42. player = shooter;
  43. duration = data.getTimer(player, "skill.fire_arrow");
  44. if(duration > 0) {
  45. if(loc_hit == null) {
  46. goto("wait");
  47. }
  48. flame = enchantment.getLevel(ench_flame, living.getHand(player));
  49. if(flame <= 0) {
  50. goto("wait");
  51. }
  52. if(!plot.check(loc_hit, player, 3, true) && !perm.has(player, "plot.bypass")) {
  53. msg.prefix(player, prefix_skill, "You have no permissions on this plot.");
  54. goto("wait");
  55. }
  56. ent_loc = entity.getLocation(projectile);
  57. if(block.isAir(ent_loc)){
  58. block.set(ent_loc, "minecraft:fire");
  59. }
  60. fire_ring(ent_loc, "minecraft:fire", 0);
  61. }
  62. goto("wait");
  63. @player_post_respawn
  64. player_uuid = player.getUuid(player);
  65. if(set.contains(survival_respawn, player_uuid)) {
  66. set.remove(survival_respawn, player_uuid);
  67. if(player.isOnAdventure(player)) {
  68. tp_loc = player.getAdventureStart(player);
  69. entity.teleport(player, tp_loc);
  70. goto("wait");
  71. }
  72. amount = skill.getAmount(player, "skill.comeback");
  73. if(skill.isActivated(player, "skill.comeback") && amount > 0) {
  74. new_amount = amount - 1;
  75. skill.setAmount(player, "skill.comeback", new_amount);
  76. msg.prefix(player, prefix_skill, concat("Used Comeback. New amount: ", text.number(new_amount)));
  77. entity.teleport(player, getDeathLoc(player));
  78. goto("wait");
  79. }
  80. entity.teleport(player, world.getServerSpawn());
  81. }
  82. goto("wait");
  83. @living_death
  84. if(isPlayer(living_entity)) {
  85. player = living_entity;
  86. amount = skill.getAmount(player, "skill.subcu_inv");
  87. if(skill.isActivated(player, "skill.subcu_inv") && amount > 0) {
  88. new_amount = amount - 1;
  89. skill.setAmount(player, "skill.subcu_inv", new_amount);
  90. msg.prefix(player, prefix_skill, concat("Used Subcutaneous Inventory. New amount: ", text.number(new_amount)));
  91. } else {
  92. player.dropInventory(player, loc);
  93. }
  94. killer = player.getFromDamageSource(damage_source);
  95. if(isPlayer(killer)) {
  96. amount = skill.getAmount(player, "skill.head_human");
  97. if(amount >= 1) {
  98. if(perm.has(player, "isTeam")) {
  99. temp = math.random(1, 20);
  100. } else {
  101. temp = math.random(1, 5);
  102. }
  103. if(temp == 1) {
  104. item.drop(loc, player.getHead(player.getUuid(player), player.getName(player)));
  105. }
  106. }
  107. }
  108. goto("wait");
  109. }
  110. killer = player.getFromDamageSource(damage_source);
  111. if(isPlayer(killer)) {
  112. r = math.random(1, 20);
  113. if(r == 1) {
  114. amount = skill.getAmount(killer, "skill.head_monster");
  115. if(amount >= 1) {
  116. entity_type = entity.getType(living_entity);
  117. if(entity_type == "creeper") {
  118. item.drop(loc, read.item("minecraft:creeper_head"));
  119. goto("wait");
  120. }
  121. if(entity_type == "zombie") {
  122. item.drop(loc, read.item("minecraft:zombie_head"));
  123. goto("wait");
  124. }
  125. if(entity_type == "skeleton") {
  126. item.drop(loc, read.item("minecraft:skeleton_skull"));
  127. goto("wait");
  128. }
  129. }
  130. }
  131. }
  132. goto("wait");
  133. @block_break
  134. duration = data.getTimer(player, "block_down");
  135. if(duration > 0) {
  136. do = true;
  137. loc = loc.mod(block_loc, 0, -1, 0);
  138. b_type = block.getType(loc);
  139. if(b_type == "minecraft:bedrock" || b_type == "minecraft:end_portal_frame") {
  140. do = false;
  141. }
  142. if(!plot.check(loc, player, 2, true)) {
  143. do = false;
  144. }
  145. if(do) {
  146. block.break(loc, player);
  147. }
  148. }
  149. duration = data.getTimer(player, "block_up");
  150. if(duration > 0) {
  151. do = true;
  152. loc = loc.mod(block_loc, 0, 1, 0);
  153. b_type = block.getType(loc);
  154. if(b_type == "minecraft:bedrock" || b_type == "minecraft:end_portal_frame") {
  155. do = false;
  156. }
  157. if(!plot.check(loc, player, 2, true)) {
  158. do = false;
  159. }
  160. if(do) {
  161. block.break(loc, player);
  162. }
  163. }
  164. if(block_type == "minecraft:cobweb") {
  165. if(cancel) {
  166. goto("wait");
  167. }
  168. hand_item = living.getHand(player);
  169. if(!item.hasTag(sword_tag, hand_item)) {
  170. goto("wait");
  171. }
  172. amount = skill.getAmount(player, "skill.cobweb_miner");
  173. if(amount <= 0) {
  174. goto("wait");
  175. }
  176. if(!skill.isActivated(player, "skill.cobweb_miner")) {
  177. goto("wait");
  178. }
  179. location = loc.mod(block_loc, 0, 0, 0);
  180. cobweb_X = loc.getX(location);
  181. cobweb_Y = loc.getY(location);
  182. cobweb_Z = loc.getZ(location);
  183. cobweb_radius = 1;
  184. unbreaking_level = enchantment.getLevel(ench_unbreaking, hand_item);
  185. for(a = -cobweb_radius; a < cobweb_radius + 1; a++) {
  186. loc.setX(location, cobweb_X + a);
  187. for(b = -cobweb_radius; b < cobweb_radius + 1; b++) {
  188. loc.setY(location, cobweb_Y + b);
  189. for(c = -cobweb_radius; c < cobweb_radius + 1; c++) {
  190. loc.setZ(location, cobweb_Z + c);
  191. if(math.abs(a) + math.abs(b) + math.abs(c) + math.random(0, 2) < cobweb_radius + 2) {
  192. shear_cobweb(location, block_type, player, unbreaking_level);
  193. }
  194. }
  195. }
  196. }
  197. goto("wait");
  198. }
  199. if(block.hasTag(leaves_tag, block)) {
  200. if(cancel) {
  201. goto("wait");
  202. }
  203. hand_item = living.getHand(player);
  204. if(item.getType(hand_item) != "minecraft:shears") {
  205. goto("wait");
  206. }
  207. if(block.property.getValue(block_loc, prop_persistent)){
  208. goto("wait");
  209. }
  210. amount = skill.getAmount(player, "skill.better_shears");
  211. if(amount <= 0) {
  212. goto("wait");
  213. }
  214. if(!skill.isActivated(player, "skill.better_shears")) {
  215. goto("wait");
  216. }
  217. location = loc.mod(block_loc, 0, 0, 0);
  218. shears_X = loc.getX(location);
  219. shears_Y = loc.getY(location);
  220. shears_Z = loc.getZ(location);
  221. unbreaking_level = enchantment.getLevel(ench_unbreaking, hand_item);
  222. radius = enchantment.getLevel(ench_sharpness, hand_item);
  223. if(radius > 0) {
  224. cancel = true;
  225. }
  226. orig_item = block.toStack(location);
  227. for(a = -radius; a < radius + 1; a++){
  228. loc.setX(location, shears_X + a);
  229. for(b = -radius; b < radius + 1; b++){
  230. loc.setY(location, shears_Y + b);
  231. for(c = -radius; c < radius + 1; c++){
  232. loc.setZ(location, shears_Z + c);
  233. if(math.abs(a) + math.abs(b) + math.abs(c) + math.random(0, 2) < radius + 2) {
  234. shear_leave(location, block_type, orig_item, player, unbreaking_level);
  235. }
  236. }
  237. }
  238. }
  239. goto("wait");
  240. }
  241. goto("wait");
  242. function shear_leave(block_loc, original_block_type, original_item, player, unbreaking_level){
  243. if(block.getType(block_loc) != original_block_type) {
  244. return;
  245. }
  246. if(block.property.getValue(block_loc, $prop_persistent)) {
  247. return;
  248. }
  249. block.set(block_loc, "minecraft:air");
  250. item.drop(block_loc, original_item);
  251. if(player.isSurvival(player)) {
  252. player.damageItem(player, 1);
  253. }
  254. }
  255. function shear_cobweb(block_loc, original_block_type, player, unbreaking_level) {
  256. if(block.getType(block_loc) != original_block_type) {
  257. return;
  258. }
  259. block.break(block_loc, player);
  260. if(math.random(0, 99) < 100 / (unbreaking_level + 1)) {
  261. player.damageItem(player, 1);
  262. }
  263. }