skills.txt 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  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_data_tick");
  6. event.load("snuvi_click");
  7. event.load("block_click");
  8. prefix_skill = "§2Skill";
  9. scroll_menu_item = item.custom.create("SCROLL", 1, "§2Skills", null);
  10. setScriptVar("skills", list.new());
  11. //skill.add(skill_name, tech_name, item, description, cost, permanent, active, toggleable, cooldown, mana, time)
  12. skill.add("Keep Inventory", "skill.subcu_inv", "minecraft:chest", "Keeps the inventory on death", 10, false, false, true, 0, 0, null);
  13. skill.add("Comeback", "skill.comeback", "minecraft:respawn_anchor", "Respawn at your death location with /comeback", 15, false, false, false, 0, 0, null);
  14. 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);
  15. //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);
  16. //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);
  17. //skill.add("Fly 10min", "skill.fly10min", "minecraft:elytra", "You can fly for 10 minutes", 500, false, true, false, 0, 0, 600);
  18. //skill.add("Grow", "skill.grow", "minecraft:farmland", "Grow seeds in radius 5", 25, false, true, false, 0, 0, null);
  19. //skill.add("Haste", "skill.haste", "minecraft:iron_pickaxe", "Haste for 2 minutes", 25, false, true, false, 0, 0, 120);
  20. //skill.add("Speed", "skill.speed", "minecraft:iron_boots", "Speed for 2 minutes", 25, false, true, false, 0, 0, 120);
  21. //skill.add("Jump Boost", "skill.jump_boost", "minecraft:rabbit_foot", "JumpBoost Lvl.2 for 2 minutes", 25, false, true, false, 0, 0, 120);
  22. //skill.add("Dolphin", "skill.dolphin", "minecraft:fire_coral", "Swim like a dolphin for a minute", 25, false, true, false, 0, 0, 60);
  23. //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);
  24. //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);
  25. skill.add("Timber", "skill.timber", "minecraft:iron_axe", "Break whole trees with an axe", 4096, true, false, true, 0, 0, null);
  26. //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);
  27. //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);
  28. //skill.add("Cobweb Miner", "skill.cobweb_miner", "minecraft:cobweb", "Swords increase the radius for destruction of cobwebs", 250, true, false, true, 0, 0, null);
  29. death_loc_map = map.new();
  30. //sword_tag = item.getTag("km:sword");
  31. //dye_tag = item.getTag("km:dye");
  32. leaves_tag = block.getTag("minecraft:leaves");
  33. //prop_persistent = block.getProperty("persistent");
  34. air_mat = material.get("AIR");
  35. water_mat = material.get("WATER");
  36. ladder_mat = material.get("LADDER");
  37. msg("dev", text.new("§bSkills §rloaded."));
  38. @wait
  39. wait();
  40. //Wenn Event aus Survival-Welten, dann wird er verarbeitet
  41. if(event == "living_death") {
  42. loc = entity.getLocation(living_entity);
  43. } else {
  44. loc = entity.getLocation(player);
  45. }
  46. world_name = world.getName(loc.getWorld(loc));
  47. if(world.isSurvName(world_name)) {
  48. ignoreGoto(event);
  49. }
  50. goto("wait");
  51. @snuvi_click
  52. item = inv.getItem(inv, inv_slot);
  53. item.removeFlag(item, "HIDE_DESTROYS");
  54. title_string = string.text(inv_title);
  55. if(item == scroll_menu_item) {
  56. if(title_string == "Lumberjack") {
  57. if(!player.unlockedLumberjack(player)) {
  58. msg.prefix(player, prefix_skill, "Skillshop is locked. Do a quest first.");
  59. goto("wait");
  60. }
  61. skill.showShop(player, "skill.timber", "skill.bet_lad", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
  62. goto("wait");
  63. }
  64. if(title_string == "Mage") {
  65. if(!player.unlockedMage(player)) {
  66. msg.prefix(player, prefix_skill, "Skillshop is locked. Do the 'Mage' quest at the 'Mage Guard' first.");
  67. goto("wait");
  68. }
  69. skill.showShop(player, "skill.subcu_inv", "skill.comeback", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
  70. //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);
  71. }
  72. goto("wait");
  73. }
  74. if(title_string == "Skillshop") {
  75. if(item == null) {
  76. goto("wait");
  77. }
  78. skill_name = string.removeFormat(string.text(item.getName(item)));
  79. if(skill_name == "") {
  80. goto("wait");
  81. }
  82. tech_name = skill.getTechName(skill_name);
  83. if(skill.isPermanent(tech_name)) {
  84. amount = skill.getAmount(player, tech_name);
  85. if(amount >= 1) {
  86. goto("wait");
  87. }
  88. }
  89. cost = skill.getCost(tech_name);
  90. if(!hasEnoughMoney(player, cost)) {
  91. msg.prefix(player, prefix_skill, "Not enough snuvis.");
  92. goto("wait");
  93. }
  94. money.sub(player, cost);
  95. skill.addAmount(player, tech_name, 1);
  96. inv.setItem(inv, inv_slot, skill.getShopItem(player, tech_name));
  97. }
  98. goto("wait");
  99. @player_data_tick
  100. if(var == "fly") {
  101. tpBottom(player);
  102. player.setFly(player, false);
  103. msg.prefix(player, prefix_skill, "Fly time is over.");
  104. }
  105. goto("wait");
  106. @projectile_hit
  107. if(!isPlayer(shooter)) {
  108. goto("wait");
  109. }
  110. player = shooter;
  111. duration = data.getTimer(player, "skill.fire_arrow");
  112. if(duration > 0) {
  113. if(loc_hit == null) {
  114. goto("wait");
  115. }
  116. flame = enchantment.getLevel(ench_flame, living.getHand(player));
  117. if(flame <= 0) {
  118. goto("wait");
  119. }
  120. if(!plot.check(loc_hit, player, 3, true) && !perm.has(player, "plot.bypass")) {
  121. msg.prefix(player, prefix_skill, "You have no permissions on this plot.");
  122. goto("wait");
  123. }
  124. ent_loc = entity.getLocation(projectile);
  125. if(block.isAir(ent_loc)){
  126. block.set(ent_loc, "minecraft:fire");
  127. }
  128. fire_ring(ent_loc, "minecraft:fire", 0);
  129. }
  130. goto("wait");
  131. @living_death
  132. if(isPlayer(living_entity)) {
  133. player = living_entity;
  134. loc = entity.getLocation(player);
  135. amount = skill.getAmount(player, "skill.subcu_inv");
  136. if(skill.isActivated(player, "skill.subcu_inv") && amount > 0) {
  137. new_amount = amount - 1;
  138. skill.setAmount(player, "skill.subcu_inv", new_amount);
  139. msg.prefix(player, prefix_skill, string.concat("Used Subcutaneous Inventory. New amount: ", string.number(new_amount)));
  140. } else {
  141. player.dropInventory(player, loc);
  142. }
  143. killer = player.getFromDamageSource(damage_source);
  144. if(isPlayer(killer)) {
  145. amount = skill.getAmount(player, "skill.head_human");
  146. if(amount >= 1) {
  147. if(perm.has(player, "isTeam")) {
  148. temp = math.random(1, 20);
  149. } else {
  150. temp = math.random(1, 5);
  151. }
  152. if(temp == 1) {
  153. item.drop(loc, player.getHead(player.getUuid(player), player.getName(player)));
  154. }
  155. }
  156. }
  157. goto("wait");
  158. }
  159. killer = player.getFromDamageSource(damage_source);
  160. if(isPlayer(killer)) {
  161. r = math.random(1, 20);
  162. if(r == 1) {
  163. amount = skill.getAmount(killer, "skill.head_monster");
  164. if(amount >= 1) {
  165. entity_type = entity.getType(living_entity);
  166. if(entity_type == "creeper") {
  167. item.drop(loc, read.item("minecraft:creeper_head"));
  168. goto("wait");
  169. }
  170. if(entity_type == "zombie") {
  171. item.drop(loc, read.item("minecraft:zombie_head"));
  172. goto("wait");
  173. }
  174. if(entity_type == "skeleton") {
  175. item.drop(loc, read.item("minecraft:skeleton_skull"));
  176. goto("wait");
  177. }
  178. }
  179. }
  180. }
  181. goto("wait");
  182. @block_break
  183. goto("wait");
  184. duration = data.getTimer(player, "block_down");
  185. if(duration > 0) {
  186. do = true;
  187. loc = loc.mod(block_loc, 0, -1, 0);
  188. b_type = block.getType(loc);
  189. if(b_type == "minecraft:bedrock" || b_type == "minecraft:end_portal_frame") {
  190. do = false;
  191. }
  192. if(!plot.check(loc, player, 2, true)) {
  193. do = false;
  194. }
  195. if(do) {
  196. block.break(loc, player);
  197. }
  198. }
  199. duration = data.getTimer(player, "block_up");
  200. if(duration > 0) {
  201. do = true;
  202. loc = loc.mod(block_loc, 0, 1, 0);
  203. b_type = block.getType(loc);
  204. if(b_type == "minecraft:bedrock" || b_type == "minecraft:end_portal_frame") {
  205. do = false;
  206. }
  207. if(!plot.check(loc, player, 2, true)) {
  208. do = false;
  209. }
  210. if(do) {
  211. block.break(loc, player);
  212. }
  213. }
  214. if(block_type == "minecraft:cobweb") {
  215. if(cancel) {
  216. goto("wait");
  217. }
  218. hand_item = living.getHand(player);
  219. if(!item.hasTag(hand_item, sword_tag)) {
  220. goto("wait");
  221. }
  222. amount = skill.getAmount(player, "skill.cobweb_miner");
  223. if(amount <= 0) {
  224. goto("wait");
  225. }
  226. if(!skill.isActivated(player, "skill.cobweb_miner")) {
  227. goto("wait");
  228. }
  229. location = loc.mod(block_loc, 0, 0, 0);
  230. cobweb_X = loc.getX(location);
  231. cobweb_Y = loc.getY(location);
  232. cobweb_Z = loc.getZ(location);
  233. cobweb_radius = 1;
  234. unbreaking_level = enchantment.getLevel(ench_unbreaking, hand_item);
  235. for(a = -cobweb_radius; a < cobweb_radius + 1; a++) {
  236. loc.setX(location, cobweb_X + a);
  237. for(b = -cobweb_radius; b < cobweb_radius + 1; b++) {
  238. loc.setY(location, cobweb_Y + b);
  239. for(c = -cobweb_radius; c < cobweb_radius + 1; c++) {
  240. loc.setZ(location, cobweb_Z + c);
  241. if(math.abs(a) + math.abs(b) + math.abs(c) + math.random(0, 2) < cobweb_radius + 2) {
  242. shear_cobweb(location, block_type, player, unbreaking_level);
  243. }
  244. }
  245. }
  246. }
  247. goto("wait");
  248. }
  249. if(block.isLeaves(block)) {
  250. if(cancel) {
  251. goto("wait");
  252. }
  253. hand_item = living.getHand(player);
  254. if(item.getType(hand_item) != "minecraft:shears") {
  255. goto("wait");
  256. }
  257. if(block.property.getValue(block_loc, prop_persistent)){
  258. goto("wait");
  259. }
  260. amount = skill.getAmount(player, "skill.better_shears");
  261. if(amount <= 0) {
  262. goto("wait");
  263. }
  264. if(!skill.isActivated(player, "skill.better_shears")) {
  265. goto("wait");
  266. }
  267. location = loc.mod(block_loc, 0, 0, 0);
  268. shears_X = loc.getX(location);
  269. shears_Y = loc.getY(location);
  270. shears_Z = loc.getZ(location);
  271. unbreaking_level = enchantment.getLevel(ench_unbreaking, hand_item);
  272. radius = enchantment.getLevel(ench_sharpness, hand_item);
  273. if(radius > 0) {
  274. cancel = true;
  275. }
  276. orig_item = block.toStack(location);
  277. for(a = -radius; a < radius + 1; a++){
  278. loc.setX(location, shears_X + a);
  279. for(b = -radius; b < radius + 1; b++){
  280. loc.setY(location, shears_Y + b);
  281. for(c = -radius; c < radius + 1; c++){
  282. loc.setZ(location, shears_Z + c);
  283. if(math.abs(a) + math.abs(b) + math.abs(c) + math.random(0, 2) < radius + 2) {
  284. shear_leave(location, block_type, orig_item, player, unbreaking_level);
  285. }
  286. }
  287. }
  288. }
  289. goto("wait");
  290. }
  291. goto("wait");
  292. @block_click
  293. if(skill.isActivated(player, "skill.bet_lad")){
  294. if (!player.isSneaking(player)){
  295. goto("wait");
  296. }
  297. if (action != "RIGHT_CLICK_BLOCK"){
  298. goto("wait");
  299. }
  300. mat = block.getType(block);
  301. item_mat = item.getType(living.getEquip(player, hand));
  302. if (mat != air_mat){
  303. if(item_mat != mat){
  304. goto("wait");
  305. }
  306. }
  307. look = entity.getLook(player);
  308. if(mat == ladder_mat){
  309. xyz = better_ladder.vertical_split(look);
  310. }
  311. elseif(false){//elseif(mat == chain_mat){
  312. if (!string.contains(string.blockData(block.getData(block)), "axis=y")){
  313. goto("wait");
  314. }
  315. //xyz = vertical_split(look);
  316. xyz = array.new(3);
  317. xyz[0] = 0;
  318. xyz[1] = -1;
  319. xyz[2] = 0;
  320. }
  321. elseif(false){//elseif(mat == rail_mat){
  322. xyz = better_ladder.horizontal_split(player);
  323. }
  324. elseif(false){//elseif(mat == vines_mat){
  325. xyz = array.new(3);
  326. xyz[0] = 0;
  327. xyz[1] = -1;
  328. xyz[2] = 0;
  329. }
  330. else{
  331. goto("wait");
  332. }
  333. better_ladder.continue_block(player, block, mat, xyz);
  334. cancel = true;
  335. }
  336. goto("wait");
  337. function shear_leave(block_loc, original_block_type, original_item, player, unbreaking_level){
  338. if(block.getType(block_loc) != original_block_type) {
  339. return;
  340. }
  341. if(block.property.getValue(block_loc, $prop_persistent)) {
  342. return;
  343. }
  344. block.set(block_loc, "minecraft:air");
  345. item.drop(block_loc, original_item);
  346. if(player.isSurvival(player)) {
  347. player.damageItem(player, 1);
  348. }
  349. }
  350. function shear_cobweb(block_loc, original_block_type, player, unbreaking_level) {
  351. if(block.getType(block_loc) != original_block_type) {
  352. return;
  353. }
  354. block.break(block_loc, player);
  355. if(math.random(0, 99) < 100 / (unbreaking_level + 1)) {
  356. player.damageItem(player, 1);
  357. }
  358. }
  359. function better_ladder.vertical_split(look){
  360. xyz = array.new(3);
  361. for (i = 0; i<3; i++){
  362. xyz[i] = 0;
  363. }
  364. if (look[1] > 0){
  365. xyz[1] = 1;
  366. }
  367. else{
  368. xyz[1] = -1;
  369. }
  370. return xyz;
  371. }
  372. function better_ladder.horizontal_split(player){
  373. xyz = array.new(3);
  374. for (i = 0; i<3; i++){
  375. xyz[i] = 0;
  376. }
  377. loc = entity.getLocation(player);
  378. yaw = loc.getYaw(loc);
  379. if (yaw < -135){
  380. xyz[2] = -1;
  381. }
  382. elseif (yaw < -45){
  383. xyz[0] = 1;
  384. }
  385. elseif (yaw < 45){
  386. xyz[2] = 1;
  387. }
  388. elseif (yaw < 135){
  389. xyz[0] = -1;
  390. }
  391. else{
  392. xyz[2] = -1;
  393. }
  394. return xyz;
  395. }
  396. function better_ladder.continue_block(player, block, of_mat, xyz){
  397. itemstack = item.new(of_mat, 1);
  398. b_loc = block.getLocation(block);
  399. set_water_logged = false;
  400. i = 0;
  401. while(true){
  402. loc.add(b_loc, xyz[0], xyz[1], xyz[2]);
  403. new_block = block.get(b_loc);
  404. if (!plot.check(b_loc, player, 23, true) || i >= 5){
  405. return;
  406. }
  407. mat = block.getType(new_block);
  408. if(mat == $air_mat){
  409. break;
  410. }
  411. elseif(mat == $water_mat){
  412. msg.dev(block.getData(new_block));
  413. if (string.contains(string.blockData(block.getData(new_block)), "falling=true")){
  414. break;
  415. }
  416. elseif(!string.contains(string.blockData(block.getData(new_block)), "level=0")){
  417. break;
  418. }
  419. elseif (block.canHaveWater(block)){
  420. set_water_logged = true;
  421. break;
  422. }
  423. else{
  424. return;
  425. }
  426. }
  427. elseif (mat != of_mat){
  428. return;
  429. }
  430. i += 1;
  431. }
  432. block.clone(block, b_loc, true);
  433. if (block.canHaveWater(block)){
  434. block.setWaterLogged(new_block, set_water_logged);
  435. }
  436. if (player.isSurvival(player)){
  437. player.removeItem(player, itemstack);
  438. }
  439. }